Only if I could read in this value: brain fried

eramgarden

Contributor
Joined
Mar 8, 2004
Messages
579
So, I have a datagrid, it displays the values, Everything is fine and dandy...

I select a row, Now, I just want the value in the first cell of whatever row I clicked:

I want that value because I want to pass it to another page...

What I have tried
Code:
Sub dg_edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)

        dg.EditItemIndex = e.Item.ItemIndex
       [b] Dim test1 = e.Item.FindControl("incid_id")
        Dim test2= e.Item.Cells(0).Text
        dim test3= e.Item.Cells(0).Controls(0)[/b]


        Response.Redirect("test.aspx")

    End Sub
[/b]

None of those work..test1 gives me "NOTHING", test2 gives me BLANK and test3 Gives me , i think the whole table definition..

This is the HTML behind it

Code:
ItemTemplate>
							<table border="0">
								<tr>
									<td align="left">
										<b>IncidID:</b></td>
									<td >
										<%# Container.DataItem("incid_id") %>
									</td>
								</tr>
								<tr>
									<td align="left"><b>Status:</b></td>
									<td>
										<%# Container.DataItem("incid_status_desc") %>
									</td>
								</tr>
							</table>
						</ItemTemplate>
						<EditItemTemplate>
							<table border="0">
							  <tr>
									<td align="left"><b>Incid:</b></td>
									<td>
										[b]<asp:TextBox id="incid_id" Width="300px" Runat="server" Text='<%# Container.DataItem("incid_id")%>' MaxLength="50">
										</asp:TextBox>[/b]
									</td>
								</tr>
								<tr>
									<td align="left"><b>Last Name:</b></td>
									<td>
										<asp:TextBox id="lastname" Width="300px" Runat="server" Text='<%# Container.DataItem("incid_status_desc")%>' MaxLength="50">
										</asp:TextBox>
									</td>
								</tr>
								</table>
						</EditItemTemplate>		
					</asp:TemplateColumn>
					<asp:EditCommandColumn ButtonType="LinkButton" EditText="<img border=0 src=./Images/bullet.gif Alt='Select'>">
						<HeaderStyle Width="50px"></HeaderStyle>
					</asp:EditCommandColumn>


Any help to get me going would be great..this is the last part i need to do...
 
you could try something like this:

Visual Basic:
strvalue = CType(e.Item.Cells(0).Controls(0), TextBox).Text

or, you could just get the record from your dataset:
Visual Basic:
strvalue = m_myDS.Tables(0).Rows(e.Item.ItemIndex).Item(0)

Good luck!
Brian
 
1.Howcome I get "object not set" error when I try

strvalue = CType(e.Item.Cells(0).Controls(0), TextBox).Text

I do have textbox set in aspx file...

2. The second one works but I need to bind the datagrid to dataset and rebind...

I like to know why the first one didnt work..
 
Back
Top