Code Comments
Programming Forum and web based access to our favorite programming groups.Hi,
I'm tring to use item template in a datagrid and added a link button in
item template. I'm loading the value of link button dynamically by
binding dataset to a datagrid. When i click that i should be able to
retrieve the value of the link button. how can i do that? Below i'm
posting my code, can you please tell me where i'm going wrong?
ASP.NET CODE
--------------
<asp:datagrid id=DataGrid1 runat="server" Width="256px" Height="225px"
AutoGenerateColumns="False" OnItemCommand ="DataGrid1_Item1">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID = "link1"
Runat=server><%#DataBinder.Eval(Container.DataItem,
"city")%></asp:LinkButton></ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
C#.NET
---------
public void DataGrid1_Item1(object sender, DataGridCommandEventArgs e)
{
string city = ((LinkButton
)DataGrid1.SelectedItem.Cells[0].Controls[0]).Text ;
Response.Write("city is:" + city);
}
Can you please tell me how to retreive the text value of link button
control in a datagrid?
Thanks & Regards,
Ratnakar Pedagani
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.