从gridview中的选定行显示外部文本框中的数据 [英] show data in outside textbox from selected row in gridview
本文介绍了从gridview中的选定行显示外部文本框中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网格视图。
I having a grid view.
<asp:GridView ID="grdPurchaseBill" runat="server" CssClass="grdcls grdstyle" ShowHeader="true" AutoGenerateColumns="false" ShowFooter="true" AllowSorting="true" ShowHeaderWhenEmpty="true" EmptyDataText="No Records Found">
<Columns>
<asp:CommandField ShowDeleteButton="True" ButtonType="Link" DeleteImageUrl="~/Images/trash.png" FooterStyle-BorderStyle="None" ItemStyle-BorderStyle="None" HeaderText="Action"> </asp:CommandField>
</asp:CommandField>
<asp:BoundField DataField="AcctId" HeaderText="Accout ID" />
<asp:BoundField DataField="CreditToAccount" />
<asp:BoundField DataField="Amount" HeaderText="Amount" />
<asp:BoundField DataField="Vat" HeaderText="VAT%" />
<asp:BoundField DataField="BasicAmount" HeaderText="Basic Amt." />
</Columns>
</asp:GridView>
和cs代码是:
and cs code is:
protected void grdPurchaseBill_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
int index = Convert.ToInt32(e.CommandName.ToString());
string accidno = grdPurchaseBill.Rows[index].Cells[2].Text.ToString();
txtCreditToAcc.Text = accidno;
txtamount.Text = grdPurchaseBill.Rows[index].Cells[3].Text.ToString();
txtVat.Text = grdPurchaseBill.Rows[index].Cells[4].Text.ToString();
txtBasicAmount.Text = grdPurchaseBill.Rows[index].Cells[5].Text.ToString();
}
catch (Exception ex)
{
}
}
当我点击网格行时,行命令有火,我看到值被分配给文本框(使用断点)。但是当我在页面上看到文本框是空的。我厌倦了。 PLZ帮助
谢谢
when i click on grid row the row command has fire and i seen the values are assign to textbox(using break point). but when i seen on page the textbox are empty. i tired from this. plz help
Thanks
推荐答案
所以你需要将另一个布尔参数传递给你的函数是注册商进行事件验证
so you need to pass another one boolean parameter to your function is registrar for event validation
e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(grdjournalvoucher, "
+ e.Row.RowIndex, false );
我想你应该使用
Convert.ToInt32(e.CommandArgument)而不是CommandName来获取Row索引值。尝试并恢复特定错误(如果有的话)。
I think you should use
Convert.ToInt32(e.CommandArgument) instead ofCommandNameto fetch the Row index value. Try it and revert with the specific errors if any.
这篇关于从gridview中的选定行显示外部文本框中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文