eramgarden Posted April 15, 2004 Posted April 15, 2004 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... Quote
cyclonebri Posted April 15, 2004 Posted April 15, 2004 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 Quote
eramgarden Posted April 16, 2004 Author Posted April 16, 2004 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.. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.