GRIDVIEW 得不到绑定列的文本值
我给girdview绑定了23列 其中前几列是固定的,其余的列是通过直接取数据绑定的 从数据库中取出来是什么样就绑定什么样
代码如下:
问题:除了这几个固定列能取到页眉的文本值 后面动态绑定的页眉值都为空 可是显示的时候确实显示了页眉 ,请高手赐教!
代码如下:
问题:除了这几个固定列能取到页眉的文本值 后面动态绑定的页眉值都为空 可是显示的时候确实显示了页眉 ,请高手赐教!
if (e.Row.RowType == DataControlRowType.Header)
{
for (int iColums = 0; iColums < dt.Rows.Count; iColums++)
{//循环在列表中要隐藏显示的列
strColums = dt.Rows[iColums][0].ToString();
for (int iCells = 0; iCells < e.Row.Cells.Count; iCells++)
{//循环当前绑定列表,从中找到与当前要隐藏的列名同名的表头列,将该cells置为false以达到隐藏显示列的目的
if (e.Row.Cells[iCells].Text == strColums)
{//这个地只有前面几个固定列能取到页眉的文本值 其余都为空 e.Row.Cells[iCells].Visible = false;
lInt.Add(iCells);
break;//找到后跳出内层循环继续循环要隐藏的下一列
}
}
}
}
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" OnSorting="GridView1_Sorting" AllowSorting="True"
Width="100%" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound"
CssClass="border" OnRowCreated="GridView1_RowCreated">
<AlternatingRowStyle HorizontalAlign="Center" CssClass="dbtable_data1" />
<RowStyle HorizontalAlign="Center" CssClass="dbtable_data2" VerticalAlign="Middle"></RowStyle>
<HeaderStyle CssClass="dbtable_title"></HeaderStyle>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle"></FooterStyle>
<Columns>
<asp:TemplateField HeaderText="编号">
<HeaderStyle Width="2px" />
<ItemStyle Width="2px" />
<ItemTemplate>
<asp:Label ID="lblNum" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="编辑">
<HeaderStyle Width="40px" />
<ItemTemplate>
<asp:LinkButton ID="LinkButtonEdit" runat="server" CommandName="edititem" CommandArgument='<%# Eval(PKField) %>'>
<asp:Image runat="server" AlternateText="编辑" ID="Image1" ImageUrl="~/img/modify.gif">
</asp:Image>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="删除">
<HeaderStyle Width="40px"></HeaderStyle>
<ItemTemplate>
<asp:LinkButton ID="LinkButtonDelete" runat="server" CommandName="deleteitem" CommandArgument='<%# Eval(PKField) %>'>
<asp:Image ID="Image2" runat="server" ImageUrl="~/img/delete.gif" AlternateText="删除">
</asp:Image>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="查看">
<HeaderStyle Width="40px"></HeaderStyle>
<ItemTemplate>
<asp:LinkButton ID="LinkButtonLook" runat="server" CommandName="lookitem" CommandArgument='<%# Eval(PKField) %>'>
<asp:Image ID="Image3" runat="server" ImageUrl="~/img/look.gif" AlternateText="查看详细">
</asp:Image>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="<input type='checkbox' name='allbox' onclick='javascript:selectAll();'"
Visible="false">
<HeaderStyle Width="2%"></HeaderStyle>
</asp:TemplateField>
</Columns>
<SelectedRowStyle BackColor="Cyan" CssClass="dbtable_data3" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
...全文
相关推荐
GridView固定表头和列 实例(GridView冻结表头和列)
这个与asp.net中GridView相关的一个实例,实现GridView冻结表头和列,挺好用的。
asp.net如何得到GRIDVIEW中某行某列值的方法
介绍了获得GRIDVIEW中某行某列值的方法具体步骤,有需要的朋友可以参考一下
关于GridView中显示Image图片列的方法及示例
关于GridView中显示Image图片列的方法及示例
GridView表格抬头列值复选筛选
GridView表格抬头每列增加三角图标,点击弹窗可复选该列值进行筛选。
在GridView控件中绑定列、超级链接列、模板...
管理留言界面中GridView控件中的绑定列、超级链接列、模板列等各列设置.


