[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
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)
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
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
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
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>
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.....
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
Re: Fill Text boxes on row select in datagrid
SeanGrebey thanks hi, ure a star turn
i can work with this now