悬赏园豆:5
[已解决问题]
解决于 2008-03-25 13:13
<P> <asp:GridView ID="gvOrderSetWithEscrow" runat="server" <BR> <Columns><BR> <asp:boundfield DataField="UserName" HeaderText="用户名" ReadOnly="True"><BR> </asp:boundfield><BR> <asp:templateField HeaderText="操作" ><BR> <ItemTemplate><BR> <asp:Button ID="btnPayAmount" runat="server" Text="确定" CommandName="Ok" /><BR> </ItemTemplate><BR> </asp:TemplateField><BR> </Columns><BR> </asp:GridView></P>
<P>---------------------------<BR> protected void gvOrderSetWithEscrow_RowCommand(object sender, GridViewCommandEventArgs e)<BR> { <BR> if (e.CommandName == "Ok")<BR> { Control cmdControl = e.CommandSource as Control; <BR> GridViewRow row = cmdControl.NamingContainer as GridViewRow;<BR> int rowindex = row.RowIndex;<BR> if (row.RowType == DataControlRowType.DataRow)<BR> { <FONT color=#ff0000> string username = gvOrderSetWithEscrow.Rows[rowindex].Cells[0].Text.ToString();</FONT><FONT color=#000000>//</FONT>这里,我不想通过 <FONT color=#ff0000>0 </FONT>来取值,而是通过绑定的列名[username]来取值,应该怎么取
问题补充:
如果存在多列的话,我还要数清楚1,2,3,4等等,那很麻烦,我想通过列名来获取值,这样会更好一点,无论html中怎么变化,.cs中就不用更改了
伊牛娃
|
菜鸟二级
|
园豆:
207
提问于:2008-03-24 10:36