Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
ratnakarp@gmail.com #1
Retreving the text value of LinkButton in template column of a datagrid
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.Eva*l(Container.DataIte m,
"city")%></asp:LinkButton>
</It*emTemplate>
</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
ratnakarp@gmail.com Guest
-
How to set different label value in datagrid template column?
Hi all, I have a datagrid with a stock label "lblStock". Here's is what i what to do : 1. If the quantity value retrieved from database is = 0... -
HeaderTemplate in Template Column in a datagrid
Hi, I have a checkbox in the header of a template column in a datagrid. How can I check during runtime that whether checkbox is checked or not? ... -
Dinamically changing the Text Field of a LinkButton in a DataGrid
Hello, I've run into a problem and I'm not sure if this is a limitation of dotNet or I'm doing something bad, I've a TemplateColumn in a... -
Bound Column or Template Column (w dAdapater?) in DataGrid
I am able to get the data using DataAdapter and the DataReader. I am more inclined to use DataAdapter because I want to update the data on the SQL... -
DataGrid / Template Column
I have a DataGrid with a template column (displaying a checkbox). The rows of the datagrid are being populated from a db table. Currently, only one... -
alto #2
Re: Retreving the text value of LinkButton in template column of a datagrid
Ratnakar,
you don't use SelectedItem on your grid. Everything you need is in the
DataGridCommandEventArgs object, passsed as param. So you'll have smt like
this:
( (<your cast here>)e.Item.Cells[<column index here>] ).<property you need>
Good luck!
<ratnakarp@gmail.com> wrote in message
news:1116341089.431257.111120@f14g2000cwb.googlegr oups.com...
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.Eva*l(Container.DataIte m,
"city")%></asp:LinkButton>
</It*emTemplate>
</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
alto Guest
-
star #3
Re: Retreving the text value of LinkButton in template column of a datagrid
please try this.
public void datagrid1_Item1(Object sender,DataGridItemEventArgs e)
{
string City=((LinkButton)(e.Item.FindControl("LnkButtonNa me"))).Text;//LNKButtonName indicates name of your link button
}star Guest
-
Unregistered #4
Re: Retreving the text value of LinkButton in template column of a datagrid
please try this
public void datagrid1_Item1(Object sender,DataGridItemEventArgs e)
{
string City=((LinkButton)(e.Item.FindControl("LnkButtonNa me"))).Text;//LNKButtonName indicates name of your link button
}Unregistered Guest



Reply With Quote

