悬赏分:5 浏览:670 次
<asp:GridView ID="gvOrderSetWithEscrow" runat="server"
<Columns>
<asp:boundfield DataField="UserName" HeaderText="用户名" ReadOnly="True">
</asp:boundfield>
<asp:templateField HeaderText="操作" >
<ItemTemplate>
<asp:Button ID="btnPayAmount" runat="server" Text="确定" CommandName="Ok" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
---------------------------
protected void gvOrderSetWithEscrow_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Ok")
{ Control cmdControl = e.CommandSource as Control;
GridViewRow row = cmdControl.NamingContainer as GridViewRow;
int rowindex = row.RowIndex;
if (row.RowType == DataControlRowType.DataRow)
{ string username = gvOrderSetWithEscrow.Rows[rowindex].Cells[0].Text.ToString();//这里,我不想通过 0 来取值,而是通过绑定的列名[username]来取值,应该怎么取