Hi,
I have a GridView which displays product details. I have a link button called 'View Details' in a template field in the gridview. When the user clicks on the link button, I want to pass the ProductID of that row to a JAVASCRIPT funtion which I call in the click event of that link button(OnClientClick). Can you please help me?
Thanks,
Loading
Ryan AlfordPosted Aug 15, 2008, 2:21 PM
// if your ProductID is in the second column of the row.
GridViewRow row = gdvEmployeeFrames.SelectedRow;
string productID = row.Cells[1].Value.ToString();
I haven't tested it so I do not know if that will work when clicking on a hyperlink template column.
r pPosted Aug 22, 2008, 11:54 AM
Md MushtaquePosted Aug 17, 2008, 4:52 AM
<
asp:GridView id="GridView1" Runat="Server" DataKeyNames="ProductID" AutoGenerateColumns="false" AllowPaging="True" PageSize="10" width="100%" CaptionAlign="Top" AllowSorting="true" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnPageIndexChanging="GridView1_PageIndexChanging" onSorting="GridView1_Sorting" EmptyDataText="No Records Found"> <Columns>......................
...........................
<
asp:TemplateField HeaderText=""> <ItemTemplate> <a href='javascript:showReport("<%# Eval("ProductID") %>");'><img src='images\information.gif' alt='Click to Know the Details of Record' border="0" align="middle" />a> ItemTemplate> <ItemStyle HorizontalAlign="center" /> <HeaderStyle Width="20px" /> asp:TemplateField>This is tested so it will work