请教GridView的取值问题~~
小弟接触Asp.net实在不久,对GridView不熟悉。请教一下。
我的页面上调用了一个Gridview控件,代码如下:
<asp:GridView ID= "GridView1 " runat= "server " AllowPaging= "True " AutoGenerateColumns= "False " CellPadding= "4 " DataSourceID= "SqlDataSource1 " ForeColor= "#333333 " GridLines= "None " Width= "100% " OnRowDataBound= "GridView1_RowDataBound ">
<FooterStyle BackColor= "#5D7B9D " Font-Bold= "True " ForeColor= "White " />
<Columns>
<asp:BoundField DataField= "memid " HeaderText= "memid " SortExpression= "memid " />
<asp:BoundField DataField= "memname " HeaderText= "客户名称 " SortExpression= "memname " />
</Columns>
<RowStyle BackColor= "#F7F6F3 " ForeColor= "#333333 " />
<EditRowStyle BackColor= "#999999 " />
<SelectedRowStyle BackColor= "#E2DED6 " Font-Bold= "True " ForeColor= "#333333 " />
<PagerStyle BackColor= "#284775 " ForeColor= "White " HorizontalAlign= "Center " />
<HeaderStyle BackColor= "#5D7B9D " Font-Bold= "True " ForeColor= "White " />
<AlternatingRowStyle BackColor= "White " ForeColor= "#284775 " />
</asp:GridView>
其中GridView1_RowDataBound事件的代码如下:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex > -1)
{
e.Row.Attributes.Add( "onDblClick ", "window.open( 'showmeminfo.aspx?memid= " + e.Row.Cells[0].Text + " ', ' ', ' ') ");
}
}
程序运行是正常的,但是我在GridView,并不想把memid这个字段显示出来,但如果我不把memid加入gridview那么e.Row.Cells[0].Text就取到的memname字段的值,把memid的visible设置为false,那么e.Row.Cells[0].Text就取不到值。像这种情况该如何在RowDataBound事件中取得memid的值呢????
还望各位指点一下,多谢!
------解决方案--------------------不要用绑定列,转换成模版列就可以了。
或者直接用模版列放label读数据。
------解决方案-------------------- <asp