我试图从 gridview 中选择一个值,但我返回空字符串。
<asp:GridView ID="GridViewLedger" runat="server" Width="100%" AutoGenerateColumns="False"
ShowFooter="True" DataKeyNames="AccountID" OnRowCommand="GridViewLedger_RowCommand"
CssClass="table table-hover table-striped table-bordered">
<Columns>
<asp:TemplateField HeaderText="InvoiceNo" SortExpression="InvoiceNo">
<ItemTemplate>
<asp:LinkButton ID="btnClickInvoiceNo" runat="server" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CommandName="InvoiceNo" Text='<%# Eval("InvoiceNo") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我在这里删除了所有不相关的列,
protected void GridViewLedger_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
string InvoiceNo = GridViewLedger.Rows[index].Cells[4].Text;
}