Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Need your help again!

I have created a gridview in asp.net web application in vb.
I have converted one column into Link button to use the click event and send user to another page with selected criteria.

The problem is that i am unable to get the text of the selected cell text to create the variable used in new page.

I have tried selected row and row.index including many other options but not received the value yet. Please guide.

Thanks in advance

debugged further: the selected row value is nothing. And their is no option of currentrow in grid view.

XML
<asp:TemplateField HeaderText="Sub Item Name" HeaderStyle-HorizontalAlign="Center" ControlStyle-Width="200" >
                <ItemTemplate>
                 <asp:LinkButton ID="lblSubItemName" runat="server" Text='<%# Eval("SubItemName")%>' OnClick="lblSubItemName_Click">
                   </asp:LinkButton>
               </ItemTemplate>

</asp:TemplateField>


in vb.net
ItemName = TryCast(gdBOM.SelectedRow.FindControl("lblSubItemName"), LinkButton).Text
Posted
Updated 29-Jun-14 5:53am
v3

 
Share this answer
 
Comments
atul sharma 5126 30-Jun-14 1:33am    
thanks. it worked
Use the solution described at Getting selected row of aspgridview when click on link button to get hidden ID value[^].
Quote:
The problem is that when you click a button in a GridView, the row will only be a Clicked Row and not a SelectedRow. If you wanna make it the SelectedRow you have to specify CommandName="Select" in the Button's markup.
 
Share this answer
 
Comments
atul sharma 5126 29-Jun-14 12:44pm    
Tried but not working
atul sharma 5126 30-Jun-14 0:59am    
Can u pls help to convert this c# code to vb:
GridViewRow clickedRow = ((LinkButton) sender).NamingContainer as GridViewRow;
Label lblID = (Label)clickedRow.FindControl("lblID");
VICK 30-Jun-14 4:26am    
Converted CODE in VB would be...

Dim clickedRow As GridViewRow = TryCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim lblID As Label = DirectCast(clickedRow.FindControl("lblID"), Label)

Further you can use the online converterss at..

http://www.developerfusion.com/tools/convert/csharp-to-vb/?batchId=4dfb532a-795e-4b8a-8973-6e129366cf13

OR

http://converter.telerik.com/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900