Solved

Update TextBox in GridView by external Image Button

Posted on 2008-10-22
5
849 Views
Last Modified: 2012-05-05
I have 2 blank TextBoxs in GridView's TempleteField and want to get text value in both of them to code behind (aspx.vb) after input and clicking my image button. I think I should rebind Gridview before refer textbox value but I don't know how. From my example code, my both variable don't have any value.
"my.aspx.vb"

Protected Sub btn1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)

 For i = 0 To myGridView.Rows.Count - 1

  Dim TextBox1 As String = CType(myGridView.Rows(i).FindControl("TxtBox1"), TextBox).Text <---- *

  Dim TextBox2 As String = CType(myGridView.Rows(i).FindControl("TxtBox2"), TextBox).Text <---- *

   '\\\ Both of TextBox1 and TextBox2 don't have any value. There're empty.

 Next

End Sub

////////////

"my.aspx"

<asp:GridView ID="GvData" runat="server" 

AutoGenerateColumns="False" 

AllowSorting="True">

 <Columns>  

  <asp:TemplateField >

   <ItemTemplate> 

    <asp:TextBox ID="TxtBox1" runat="server" />

   </ItemTemplate>

  </asp:TemplateField>

                        

  <asp:TemplateField>

   <ItemTemplate>

    <asp:TextBox ID="TxtBox2" runat="server" />

   </ItemTemplate>

  </asp:TemplateField>

</Columns>

</asp:GridView>

Open in new window

0
Comment
Question by:Krichaya
  • 2
  • 2
5 Comments
 
LVL 10

Assisted Solution

by:jinn_hnnl
jinn_hnnl earned 250 total points
Comment Utility
IF you bind your GridView from codebehind dynamically then you might have to rebind them as the page is postedback. I dont think this is the case.

Well, you can try enable view state of the textBox to see what happen
<asp:TextBox ID="TxtBox1" EnableViewState="true" runat="server" />

JINN

0
 
LVL 22

Assisted Solution

by:prairiedog
prairiedog earned 250 total points
Comment Utility
>>>I think I should rebind Gridview before refer textbox value
If you do this, then all input is gone, that is why your TextBox controls don't have any values in your code-behind.
0
 

Author Comment

by:Krichaya
Comment Utility
Thanx JINN , but I still not get a point. It still not have any value back.

prairiedog : It's just my idea. I'm very newbie. So I don't find any way to complete it.

PS. now it still not get any value. At First, It's blank textbox in templete field. I want to input some numeric and click external image button outside gridview and send it to code-behind. Please suggest me more.

Thankyou
0
 

Accepted Solution

by:
Krichaya earned 0 total points
Comment Utility
Arghhhhhh !!!!

I found my stupid thing. I put boundata function with postback. Thanx Both of You so much. I get a correct point.
0
 
LVL 10

Expert Comment

by:jinn_hnnl
Comment Utility
Hi, sorry for the late response. I am back to my office just now.

Glad you work it out ^^.

It would be nice if you can elaborate a little more for our future reference.

JINN
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
JavaScript error 1 32
Round up to 100% in .NET 10 39
Create XML 5 30
Spacing between controls 4 15
Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now