Gridview为行添加选择复选框并更改列标题名称 [英] Gridview add select checkbox for row and change column header names
本文介绍了Gridview为行添加选择复选框并更改列标题名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我使用后面的代码来绑定我的gridview,我想知道如何在gridview中添加一个额外的列以允许用户选择行抛出复选框,我也想更改标题栏标题名称,所以你们可以帮助我吗
Hi
I am using code behind to bind my gridview and i would like to know how i can add an extra column to the gridview to allow user to select the row throw checkbox, also i want to change the header column title names, so can you guys help me please
<asp:GridView ID="MailshwGRDVIW" runat="server" HeaderStyle-BackColor="#ffc809" BorderStyle="None"
AllowPaging="true" AlternatingRowStyle-BorderStyle="None"
HeaderStyle-ForeColor="White" Width="600px" HeaderStyle-Height="25px">
</asp:GridView>
< br $> b $ b
if (Session ["UsrNme"] != null)
{
string UsrNme = Convert.ToString(Session["UsrNme"]);
DataTable MailshowDT = new DataTable();
SqlConnection MailshowCon = new SqlConnection();
String MailshowSQL = "SELECT sender, Mestitle, Date FROM mails WHERE ([Receiver] = @Receiver)";
using (SqlDataAdapter MailshowDA = new SqlDataAdapter(MailshowSQL, sc))
{
MailshowDA.SelectCommand.Parameters.AddWithValue("@Receiver", UsrNme);
MailshowDA.Fill(MailshowDT);
}
MailshwGRDVIW.DataSource = MailshowDT;
MailshwGRDVIW.DataBind();
}
推荐答案
您可以添加一个复选框并设置如下所示的标题文本
You can add a check box and set header text like below
<Columns>
<asp:TemplateField HeaderText="headettext" >
<ItemTemplate>
<asp:CheckBox ID="myCheckBox" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
我想你会得到你需要的所有东西。
GridView all in one [ ^ ]
I think you will get all that you need here.
GridView all in one[^]
这篇关于Gridview为行添加选择复选框并更改列标题名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文