Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

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

 

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...

Posted

you could try something like this:

 

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

 

or, you could just get the record from your dataset:

strvalue = m_myDS.Tables(0).Rows(e.Item.ItemIndex).Item(0)

 

Good luck!

Brian

Posted

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..

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...