For Programmers: Free Programming Magazines  


Home > Archive > C# > May 2005 > Help on itemtemplate, control and datagrid









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help on itemtemplate, control and datagrid
ratnakarp@gmail.com

2005-05-15, 8:57 pm

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com