How to fetch Radgrid itemtemplate cell value on Button click

7 posts, 0 answers
  1. Siva
    Siva avatar
    35 posts
    Member since:
    Mar 2013

    Posted 07 Mar 2013 Link to this post

    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

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Mar 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Siva
    Siva avatar
    35 posts
    Member since:
    Mar 2013

    Posted 07 Mar 2013 Link to this post

    Hi princy . I think  its not working for Gridtemplate column. for Boundcolumn its working well.. thanks for the reply pls help.
  5. Siva
    Siva avatar
    35 posts
    Member since:
    Mar 2013

    Posted 07 Mar 2013 Link to this post

    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;
    }

  6. Jaya
    Jaya avatar
    81 posts
    Member since:
    Mar 2011

    Posted 11 Jun 2015 in reply to Princy Link to this post

    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

  7. Jaya
    Jaya avatar
    81 posts
    Member since:
    Mar 2011

    Posted 11 Feb in reply to Princy Link to this post

    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
  8. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 16 Feb Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017