Results 1 to 7 of 7

Thread: How do i get checked values from textbox control in a gridview

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    8

    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.

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    8

    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

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    8

    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.

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  7. #7
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: How do i get checked values from textbox control in a gridview

    Try something like this:
    vb.net Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         If ispostback Then
    3.             Dim tbValues = From gvr In GridView1.Rows _
    4.                            Select ctype(gvr.FindControl("TextBoxIDGoesHere"), TextBox).Text
    5.  
    6.             '' lets see what we have now
    7.             For Each value In tbValues
    8.                 response.write(value)
    9.             Next
    10.         End If
    11.     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).
    Last edited by Pradeep1210; Apr 19th, 2011 at 04:12 AM. Reason: correction
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width