asp.net - Getting value from selected row in gridview -
i'm novice vb programmer trying retrieve value of selected row in gridview. haven't been able of yet. i've searched forums, none of answers have worked me. here html portion of code:
<asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" cellpadding="4" forecolor="#333333" gridlines="none" width="1032px" enablemodelvalidation="true"> <alternatingrowstyle backcolor="white" forecolor="#284775" /> <columns> <asp:templatefield headertext="date" > <itemtemplate> <asp:linkbutton id="linkbutton1" runat="server" causesvalidation="false" onclick ="linkbutton1_click" commandname="drilltp" text='<%#eval("transit_date")%>'> </asp:linkbutton> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="transit_date" headertext="date" visible="false" > <headerstyle horizontalalign="left" /> </asp:boundfield> <asp:boundfield datafield="day_type" headertext="daytype" > <headerstyle horizontalalign="left" /> </asp:boundfield> <asp:boundfield datafield="current_route_id" headertext="line" > <headerstyle horizontalalign="left" /> </asp:boundfield> <asp:boundfield datafield="bs_lname" headertext="location" > <headerstyle horizontalalign="left" /> </asp:boundfield> </columns> <editrowstyle backcolor="#999999" /> <footerstyle backcolor="#5d7b9d" font-bold="true" forecolor="white" /> <headerstyle backcolor="#5d7b9d" font-bold="true" forecolor="white" /> <pagerstyle backcolor="#284775" forecolor="white" horizontalalign="center" /> <rowstyle backcolor="#f7f6f3" forecolor="#333333" /> <selectedrowstyle backcolor="#e2ded6" font-bold="true" forecolor="#333333" /> </asp:gridview>
in visual basic, i'm trying capture selected date , place info in label, haven't been able yet. suggestions? have this:
protected sub linkbutton1_click(sender object, e eventargs) '(sender object, e datagridcommandeventargs) label1.text = gridview1.selectedrow.dataitem end sub
clearly, i'm missing something, appreciated. also, please let me know if can post question more effectively. thanks!!
you need use property value, , perhaps use tostring method.
gridview1.selectedrows(0).value.tostring()
Comments
Post a Comment