<asp:GridView ID="GridView1" runat="server" >
<Columns>
</asp:TemplateField>
<asp:BoundField DataField="t_id" HeaderText="t_id" SortExpression="t_id" />
<asp:BoundField DataField="t_name" HeaderText="t_name" SortExpression="t_name"/>
<asp:BoundField DataField="t_sex" HeaderText="t_sex" SortExpression="t_sex" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button2" runat="server" Text="编辑" CommandName="edit" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>像上面代码..怎么在一个按钮事件中判断gridview里<Columns>中的控件是 <asp:BoundField >或是 <asp:TemplateField>还是其他的控件??
<Columns>
</asp:TemplateField>
<asp:BoundField DataField="t_id" HeaderText="t_id" SortExpression="t_id" />
<asp:BoundField DataField="t_name" HeaderText="t_name" SortExpression="t_name"/>
<asp:BoundField DataField="t_sex" HeaderText="t_sex" SortExpression="t_sex" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button2" runat="server" Text="编辑" CommandName="edit" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>像上面代码..怎么在一个按钮事件中判断gridview里<Columns>中的控件是 <asp:BoundField >或是 <asp:TemplateField>还是其他的控件??
for(int i=0;i<gridview1.Rows.count;i++)
{
for(int j=0;j<gridview.Rows[i].Cells.Count;j++)
{
string str=gridview.Rows[i].cell[j].Text;//asp:boundField
//若是<asp:TemplateField>绑定的话选判断<asp:TemplateField>绑定的类型,以Label 为例吧
label有一个id为"labID"
string str=((Label)gridview.Rows[i].Cell[j].FindControl("labID")).Text;就可以以.
}}