This is a migrated thread and some comments may be shown as answers.

How to fetch Radgrid itemtemplate cell value on Button click

6 Answers 848 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Siva
Top achievements
Rank 1
Siva asked on 07 Mar 2013, 07:15 AM
Hi ,
     I tried to get a cell value from the Radgrid on clicking the button that is also present inside the radgrid. Both the label & buttons are in the GridTemplatecolumn.

Aspx file 
     

<telerik:GridTemplateColumn FilterControlAltText="Filter Status column"

HeaderText="Status" SortExpression="Status asc" UniqueName="Status">

<ItemTemplate>

<asp:Label ID="lblStatusText" Text='<%# Eval("Status")%>' runat="server"></asp:Label>

 

<asp:Button ID="btnChangeStatus" runat="server" Text="Change Status" onclick="btnChangeStatus_Click" />
</ItemTemplate>
</telerik:GridTemplateColumn>

Aspx.cs file:

 

protected void btnChangeStatus_Click(object sender, EventArgs e)

{

foreach (GridDataItem item in RadGrid2.Items)

{
Label lb = (Label)item.FindControl("lblStatusText");

Label lbOrder = (Label)item.FindControl("lblOrder");

string TemplateColumnValue = lb.Text;

string orderno = lbOrder.Text;

}

}
            Wat i get as o/p is the last row value of the radgrid in the particular page instead i want the cell values of the row on which the button is clicked. in this the lblOrder is a boundcolumn value.
 

Thanks

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Mar 2013, 07:23 AM
Hello Siva,

Try the following code to achieve the scenario.

C#:
protected void Button1_Click(object sender, EventArgs e)
    {
        Button btn = (Button)sender;
        GridDataItem item = (GridDataItem)btn.NamingContainer;
        TableCell cell = (TableCell)item["UniqueName"];
        string value = cell.Text;
}

Thanks,
Princy.
0
Siva
Top achievements
Rank 1
answered on 07 Mar 2013, 09:04 AM
Hi princy . I think  its not working for Gridtemplate column. for Boundcolumn its working well.. thanks for the reply pls help.
0
Siva
Top achievements
Rank 1
answered on 07 Mar 2013, 09:49 AM
This code works...

protected void btnChangeStatus_Click(object sender, EventArgs e)

{

Button btn = (Button)sender;

GridDataItem item = (GridDataItem)btn.NamingContainer;

Label  lb= (Label)item.FindControl("lblStatusText" );

 

string TemplateColumnValue = lb.Text;
}

0
Jaya
Top achievements
Rank 1
answered on 11 Jun 2015, 09:19 AM

Hi

Princy

 

Can you solve this

 

Hi

I saw this url for Multiple column for Autocomplete following url . But here mention DatasourceID="Sqldatasource" but i need use this same sample for call asmx method how will do this any one guide me. 

http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multicolumncombo/defaultcs.aspx

0
Jaya
Top achievements
Rank 1
answered on 12 Feb 2016, 04:40 AM
Hi
 How to Implementation AutoCompleteBox with Image for Ex:
My Control this but here i added this DataSourceID="SqlDataSource1"  but no need this i need fetch the data from database using c# and list object 
can you fixed this
 <telerik:RadComboBox RenderMode="Lightweight" ID="RadComboBox1" runat="server" Width="400" Height="400px" 
                EmptyMessage="Type an E-mail" DataSourceID="SqlDataSource1" DataTextField="ContactName"
                OnItemDataBound="RadComboBox1_ItemDataBound">
            </telerik:RadComboBox>

But My Need this
 In my AutocompleteBox shows like this -> multiple column with image then c# list object using webservices  for Data binding.

EMPID   EMPNAME    EMPIMAGE
100        NAME HERE  IMAGE HERE 

 how will do this any one fixed this
0
Viktor Tachev
Telerik team
answered on 16 Feb 2016, 09:28 AM
Hi Jaya,

Please submit a separate thread for every unrelated query you may have. This will help keep the information in a thread consistent and easier to find.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Siva
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Siva
Top achievements
Rank 1
Jaya
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or