我想为“选定的Gridview行”中的Bootstrap Modal提供一些值,因此我在gridview中创建了一个链接按钮,并在gridview中单击linkbutton后加载了该模式,这是我的链接按钮代码
<asp:TemplateField ShowHeader="False" HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="VIPTBArrange" runat="server" data-toggle="modal" data-target="#VIPTableModal" CausesValidation="False" CommandName="VIPTBArrange" Text="Edit" ForeColor="#0066CC" HorizontalAlign="Center" VerticalAlign="Middle" Width="22px"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
我的模态代码
<div class="modal fade" id="VIPTableModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
Table: <asp:Label ID="lblTableNo" runat="server" Text=""></asp:Label> TB Edit</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<asp:Label ID="lblTBType" runat="server" Text="TBType:"></asp:Label>
【<asp:Label ID="lblTBTypeContent" runat="server" Text="Testing Data"></asp:Label>】
<p></p>
<form>
<div class="form-group">
<label for="message-text" class="col-form-label">Name:</label>
<input type="text" class="form-control" ID="txtName1">
</div>
<div class="form-group">
<label for="message-text" class="col-form-label" id="optType1">Table Type:</label>
<select class="custom-select">
<option value="">Please Choose...</option>
<option value="1">Type 1</option>
<option value="2">Type 2</option>
</select>
<div class="invalid-feedback">Invalid Value</div>
</div>
<div class="form-group">
<label for="message-text" class="col-form-label">PAX:</label>
<select class="custom-select" id="optPax1">
<option value="">Please Choose...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<div class="invalid-feedback">Invalid Value</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close</button>
<button type="button" class="btn btn-primary">
Save</button>
</div>
</div>
</div>
</div>
成功弹出模态表单, 我在gridview上分配了一个事件,并使用以下代码将其引发为.cs:
protected void VIPTable_BtnClick(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "VIPTBArrange")
{
lblTableNo.Text = "Hello World";
}
}
但是将“ Hello World”带入莫代尔的标签并不成功, 我可以知道如何做到吗?非常感谢!