.net 使用gridview+bootstrap模态框
html代码:
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:Button runat="server" ID="edit" CommandArgument="<%# Container.DataItemIndex+1 %>" Text="Edit" CommandName="editLoc" CssClass="btn btn-primary" data-toggle="modal" data-target="#myModal" />
</ItemTemplate>
</asp:TemplateField>
模态框响应事件:
function getGridViewValue(con_id, con_name, current_loc) {
$('#myModal').on('shown.bs.modal', function () {
$("#con_edit_id").val(con_id);
$("#con_edit_name").val(con_name);
$("#current_edit_loc").val(current_loc);
});
}
后台:
protected void gvin_RowCommand(object sender,GridViewCommandEventArgs e)
{
if (e.CommandName=="editLoc")
{
int index = Convert.ToInt32(e.CommandArgument.ToString());
Button btn = (Button)gvin.Rows[index].FindControl("edit");
btn.Attributes.Add("onclick", "getGridViewValue('" + gvin.Rows[index].Cells[0].Text + "','" + gvin.Rows[index].Cells[1].Text + "','" + gvin.Rows[index].Cells[2].Text + "')");
}
}
相关推荐
ASP.NET GridView+Bootstrap Demo Source Code
在"ASP.NET GridView+Bootstrap Demo Source Code"中,这个示例展示了如何利用GridView实现创建(Create)、读取(Read)、更新(Update)和删除
基于Bootstrap 4的ASP.NET Web窗体中可编辑Gridview实战实现
Bootstrap 4作为当前主流的前端框架,以其强大的响应式布局和组件化设计广泛应用于现代Web开发。在ASP.NET Web Forms中,GridView控件虽功能完备,但默认样式陈旧且缺乏移动端适配能力,难以满足用户体验需求。通过集成Bootstrap 4,可显著提升表格的视觉表现与设备兼容性。为实现平滑集成,需正确引入CSS与JS资源:推荐使用CDN加速加载,或部署本地文件以增强可控性。需注意避免Bootstrap的全局样式(如table。
使用Bootstrap 4的Web窗体中的ASP.NET Gridview
还可以使用`.table-bordered`添加边框,`.table-hover`实现鼠标悬停时高亮显示行。至于数据交互,Gridview通常与C#后端代码或.NET框架的其他组件配合使用。
使用Bootstrap 4在Web窗体中可编辑的ASP.NET Gridview
在本文中,我们将深入探讨如何在ASP.NET Web Forms应用程序中使用Bootstrap 4框架创建一个可编辑的Gridview。
博文《Bootstrap Pagination for ASP.NET GridView》源代码
还可以使用`active`和`disabled`类来标识当前页和禁用状态的页。2. **ASP.NET GridView**:GridView是一个服务器端控件,用于显示和编辑表格数据。


