我们如何将数据放在GridView上的特定行索引上。 [英] How can we put data on particular row index on GridView.

查看:66
本文介绍了我们如何将数据放在GridView上的特定行索引上。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好,我有一个Gridview,它绑定数据库中的一些数据,除了Quantity Textbox。每次点击此按钮时,网格上还有一个按钮,一个数字被添加到数量框中(我想在网格上显示)。请参阅下面的代码&建议我。



XHTML:



Hi Guys, I have a Gridview which binds some data from database except Quantity Textbox. There is also a button on Grid on each click of this button one number is added to the quantity box (This I want to show on grid). Please see my code below & suggest me.

XHTML :

<asp:TextBox Style="width:32px; height:10px; position:absolute;" ID="txtDisplay" runat="server" AutoPostBack="True" OnTextChanged="txtDisplay_TextChanged"></asp:TextBox>
                                                                      <asp:Button ID="btn_Next" runat="server" CommandName="Next" CommandArgument='<%#((GridViewRow)Container).RowIndex %>' Text=">" />



代码:


Code:

protected void grdSale_RowCommand(object sender, GridViewCommandEventArgs e)
    {




if (e.CommandName == "Next")
       {
           int Index_Next = Convert.ToInt32(e.CommandArgument);
           TextBox Quantity = (TextBox)grdSale.Rows[Index_Next].FindControl("txtDisplay");
           int Val_Next = Convert.ToInt32(Quantity.Text);
           if (Val_Next != 0 && Val_Next > 1)
           {
               Val_Next = Val_Next + 1;
           }
           (TextBox)grdSale.Rows[Index_Next].FindControl("txtDisplay") = Val_Next.ToString();    // Here I'm getting error. I also convert this string to TextBox but still show error.
       }





请建议您的体验。



Kindly suggest your experience.

推荐答案

嗨大家好我这样做了:



Hi Guys I done like this :

((TextBox)grdSale.Rows[Index_Next]
                 .FindControl("txtDisplay")).Text = Val_Next.ToString();


这篇关于我们如何将数据放在GridView上的特定行索引上。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆