How do i get checked values from textbox control in a gridview
Hello, am new to aspx.net and vb, but am developing an app that is to get values from textbox controls placed in a gridview control of an aspx page when the checkbox is checked, and those values i want to put them in another textbox, pls help.
Re: How do i get checked values from textbox control in a gridview
Hello,
Welcome to the forums!!
Are you wanting this to happen on the client side, i.e. using JavaScript/jQuery, or are you looking for this to happen on the server side by first doing a PostBack to the page?
Gary
Re: How do i get checked values from textbox control in a gridview
thanks for your quick response gep13, i would like it to be at the server side
Re: How do i get checked values from textbox control in a gridview
Hello,
Without additional code, the checking of the CheckBox itself won't result in the RowCommand event of the GridView firing. But what you could do it add a Button to the Row of the GridView, then when that is pushed, inspect the current checked state of the CheckBox, and take appropriate action.
You can find details of the RowCommand here:
http://msdn.microsoft.com/en-us/libr...owcommand.aspx
Let me know if this doesn't make sense.
Gary
Re: How do i get checked values from textbox control in a gridview
Yeah thanks alot, it does make sense a little, but not addressing the issue, i want to achieve something that looks like u adding recipient email addresses to a recipient email textfield extracted from a contact webpage from my project, where by the sender checks multiple checkboxes in the gridview to send the mail to. i dont know if u understand what am saying... please help.
Re: How do i get checked values from textbox control in a gridview
Hello there,
Yes, I am not sure that I follow what you are asking. From what you have described, I think that you can achieve it using the technique that I have pointed out, but perhaps not.
Can you please provide some additional information?
Gary
Re: How do i get checked values from textbox control in a gridview
Try something like this:
vb.net Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If ispostback Then
Dim tbValues = From gvr In GridView1.Rows _
Select ctype(gvr.FindControl("TextBoxIDGoesHere"), TextBox).Text
'' lets see what we have now
For Each value In tbValues
response.write(value)
Next
End If
End Sub
(NB: this is freehand typed code, so might contain typos. But it should basically give you an idea how to go about it).