R
ratnakarp
Hi,
I'm tring to use template column 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 linkbutton on the webform
,i should be able to retrieve the text 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>
</aspataGrid>
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
I'm tring to use template column 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 linkbutton on the webform
,i should be able to retrieve the text 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>
</aspataGrid>
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