【发布时间】:2012-07-24 05:10:19
【问题描述】:
我有一个像下面这样的网格。
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" s
onrowcommand="GridView1_RowCommand">
<Columns>
<asp:ButtonField DataTextField="Name" HeaderText="Name" />
<asp:BoundField DataField="ArrDate" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Arr Date" />
<asp:BoundField HeaderText="Dep Date" DataField="DepDate"
DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField HeaderText="Mail" DataField="Mail" />
<asp:BoundField HeaderText="Status" DataField="Status" />
<asp:BoundField DataField="ResId" HeaderText="ResId" Visible="False" />
</Columns>
</asp:GridView>
在代码后面:-
try
{
string text = GridView1.Rows[2].Cells[5].Text;
ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('ResId = " + text + ".');", true);
}
catch { }
现在消息显示 - RegId =。
我无法获得价值。所以我将 RedId BoundField 更改为可见。现在我得到了价值。
即 RegId =6。
我现在有两个问题 -
1) 如何获取不可见列中的 RegId 值。 2)我如何找到我点击的行值... bzs唯一我可以在代码中更改 ROWVALUE ..
string text = GridView1.Rows[ROWVALUE].Cells[5].Text;
【问题讨论】: