Results 1 to 9 of 9

Thread: [RESOLVED] Fill Text boxes on row select in datagrid THANKS SEAN

  1. #1

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Resolved [RESOLVED] Fill Text boxes on row select in datagrid THANKS SEAN

    i have a datagrid and put a select button column

    when the select buttton is pressed i wish to load the data into textboxes and change the colour of the row,

    at the moment when the select button is presssed nothing actually happens

    does anyone know how to select the row in this way
    is it possible to change the colour of the row selected

    Thanks
    Last edited by d2005; Sep 26th, 2005 at 10:31 AM.
    it works 60% of the time, all the time.

  2. #2
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Fill Text boxes on row select in datagrid

    You should be able to do that using the ItemCommand event of the Datagrid and MyDataGrid.Items(e.Item.ItemIndex)
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  3. #3

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: Fill Text boxes on row select in datagrid

    yeah ive been messin around with it cant seem to get anything working-
    nightmare
    this hangover aint helpin niether lol
    it works 60% of the time, all the time.

  4. #4
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Fill Text boxes on row select in datagrid

    I haven't done it, but I assume it would be pretty straight forward.

    Private Sub dgMyGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCalls.ItemCommand

    If e.CommandName = "Select" Then

    dgMyGrid.Items(e.Item.ItemIndex).ForeColor = Color.Red

    Dim txtMyText As Web.UI.WebControls.TextBox = e.Item.FindControl("MyTextBox")

    txtMyText.Text = SomeFunctionToGetDataFromDB()

    End If

    End Sub
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  5. #5

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: Fill Text boxes on row select in datagrid

    i put this in to seee if i could chanbe colour to start off with,
    nothing happens

    i had to change handles dgcalls to my datagrid name is this coorect
    on pressing select button nothin happens


    VB Code:
    1. Private Sub dgMyGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgMsgIn.ItemCommand
    2.  
    3.         If e.CommandName = "Select" Then
    4.  
    5.             dgMsgIn.Items(e.Item.ItemIndex).BorderColor = Color.Red
    6.  
    7.      
    8.  
    9.         End If
    10.  
    11.     End Sub
    it works 60% of the time, all the time.

  6. #6
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Fill Text boxes on row select in datagrid

    Are you sure your Datagrid has borders? Is your commandname set to Select? Did you put a break point in there and make sure it stepped through?

    <asp:ButtonColumn Text="Select" CommandName="Select"></asp:ButtonColumn>
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  7. #7

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: Fill Text boxes on row select in datagrid

    The Colour Change Works Now Dude Thats A Million

    can i not change this
    VB Code:
    1. Dim txtMyText As Web.UI.WebControls.TextBox = e.Item.FindControl("MyTextBox")
    2. txtMyText.Text = SomeFunctionToGetDataFromDB()

    to something like when the select button pressed txtTime.text = column 3, txtmsg.text=coulmn 4 etc.....
    Last edited by d2005; Sep 26th, 2005 at 09:52 AM.
    it works 60% of the time, all the time.

  8. #8
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Fill Text boxes on row select in datagrid

    Yeah, what I showed you was for Text Boxes embedded in the Datagrid in Template Columns. if they are outside the datagrid, I'm sure you can do something along the lines of:

    Text1.Text = dgMyGrid.Items(e.Item.ItemIndex).Cells(3).Text
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  9. #9

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: Fill Text boxes on row select in datagrid

    SeanGrebey thanks hi, ure a star turn

    i can work with this now
    it works 60% of the time, all the time.

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