我想要gridview中的文本框值 [英] i want textbox value in gridview
本文介绍了我想要gridview中的文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gridview控件,因为我拥有所有文本框,而在gridview之外,我还有一个文本框,无论我在文本框中输入的值是多少,我都希望在gridview文本框中显示该值
这是我的代码
i have a gridview control in that i have all the textboxes and out side the gridview i have one more textbox, what ever the value that i enter in the textbox i want to display that value in gridview textboxes
this is my code
<asp:TextBox ID="TextBox1" runat="server">
<asp:GridView ID="GridView1" runat="server">
<columns>
<asp:TemplateField HeaderText="Maxmarks">
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%=(TextBox1.Text) %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</columns>
这就是我写的
提前谢谢您.
this is what i have written
thank you in advance
推荐答案
在TextBox1中触发TextChanged事件.
详细信息此处 [
Fire the TextChanged event in the TextBox1.
More information here[^].
以下解决方案可能对您有帮助....
不要设置内部Testbox的Text属性.
the following solution may helpful for you....
don''t set the Text Property of your inner Testbox .
protected void btnEnter_Click(object sender, EventArgs e)
{
//comment-use this commented code if you have to set value of textbax for perticullar row
//rowNumber = 0
//GridViewRow row = (GridViewRow)grvTest.Rows[rowNumber];
//TextBox txt = (TextBox)row.FindControl("txtTextBoxInGrid");
//txt.Text = txtTextBoxOutsideGrid.Text;
// use this code to set value of all text boxes in gridview
foreach (GridViewRow row in grvTest.Rows)
{
TextBox txt = (TextBox)row.FindControl("txtTextBoxInGrid");
txt.Text = txtTextBoxOutsideGrid.Text;
}
}
这篇关于我想要gridview中的文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文