|
-
Sep 26th, 2005, 07:02 AM
#1
Thread Starter
Fanatic Member
[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.
-
Sep 26th, 2005, 08:31 AM
#2
Frenzied Member
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.
-
Sep 26th, 2005, 08:45 AM
#3
Thread Starter
Fanatic Member
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.
-
Sep 26th, 2005, 09:01 AM
#4
Frenzied Member
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.
-
Sep 26th, 2005, 09:17 AM
#5
Thread Starter
Fanatic Member
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:
Private Sub dgMyGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgMsgIn.ItemCommand
If e.CommandName = "Select" Then
dgMsgIn.Items(e.Item.ItemIndex).BorderColor = Color.Red
End If
End Sub
it works 60% of the time, all the time.
-
Sep 26th, 2005, 09:32 AM
#6
Frenzied Member
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.
-
Sep 26th, 2005, 09:36 AM
#7
Thread Starter
Fanatic Member
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:
Dim txtMyText As Web.UI.WebControls.TextBox = e.Item.FindControl("MyTextBox")
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.
-
Sep 26th, 2005, 10:11 AM
#8
Frenzied Member
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.
-
Sep 26th, 2005, 10:30 AM
#9
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|