Jose Saiz

Jose Saiz

  • 1.5k
  • 260
  • 103.2k

Telerik RadGrid

Jan 14 2018 5:20 PM
Does any one have a sample of the Telerik RadGrid that I am able to select the a row from the grid and get the real value from the selected row?
 
I have tried all samples and neither one can help, when I don't get an error I get the wrong value from the selected row.
 
This is what I've been trying (default.aspx)
  1. <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" DataSourceID="SqlDataSource2" AllowSorting="True"                  
  2.                 PageSize="7" AllowPaging="True" runat="server" OnSortCommand="RadGrid1_SortCommand"  
  3.                 OnPageIndexChanged="RadGrid1_PageIndexChanged"  OnPageSizeChanged="RadGrid1_PageSizeChanged" OnEditCommand="RadGrid1_EditCommand">                  
  4.                 <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>  
  5.                 <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataSourceID="SqlDataSource2"  
  6.                     DataKeyNames="logId" AutoGenerateColumns="false" InsertItemDisplay="Top"  
  7.                     InsertItemPageIndexAction="ShowItemOnFirstPage">  
  8.                     <Columns>                        
  9.                         <telerik:GridButtonColumn DataTextField="logId" CommandName="Edit">  
  10.                         </telerik:GridButtonColumn>                            
  11.                         <telerik:GridBoundColumn DataField="log_date" UniqueName="log_date" HeaderText="Date">  
  12.                         </telerik:GridBoundColumn>  
  13.                         <telerik:GridBoundColumn DataField="log_type" UniqueName="log_type" HeaderText="Type">  
  14.                         </telerik:GridBoundColumn>  
  15.                         <telerik:GridBoundColumn DataField="client_name" UniqueName="client_name" HeaderText="Client Name">  
  16.                         </telerik:GridBoundColumn>  
  17.                         <telerik:GridBoundColumn DataField="delivery_method" UniqueName="delivery_method" HeaderText="Method">  
  18.                         </telerik:GridBoundColumn>  
  19.                         <telerik:GridBoundColumn DataField="entered_by" UniqueName="entered_by" HeaderText="Entered By">  
  20.                         </telerik:GridBoundColumn>  
  21.                         <telerik:GridBoundColumn DataField="facility_name" UniqueName="facility_name" HeaderText="Facility">  
  22.                         </telerik:GridBoundColumn>  
  23.                         <telerik:GridBoundColumn DataField="log_status" UniqueName="log_status" HeaderText="Status">  
  24.                         </telerik:GridBoundColumn>  
  25.                         <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">  
  26.                         </telerik:GridButtonColumn>  
  27.                     </Columns>  
  28.                 </MasterTableView>  
  29.                   
  30.              </telerik:RadGrid>  
  31.              <asp:SqlDataSource ID="SqlDataSource2" runat="server"></asp:SqlDataSource>  
 default.aspx.cs (Code behind)
  1. protected void LogDailyLogDataListing()  
  2.     {  
  3.         
  4.         SqlDataSource2.ConnectionString = "Connection String Here"  
  5.         SqlDataSource2.SelectCommand = "select * from table";  
  6.         this.RadGrid1.DataBind();  
  7.     }   
  8.  protected void RadGrid1_EditCommand(object sender, EventArgs e)          
  9.     {  
  10.         //- Per Telerik sample this suppose to work but it does not.  
  11.         foreach (var item in RadGrid1.SelectedItems)  
  12.         {  
  13.             if (item is GridDataItem)  
  14.             {  
  15.                 GridDataItem dataItem = item as GridDataItem; // found the   
  16.                string sLogId = dataItem["logId"]; // found the cell  
  17.             }  
  18.         }  
  19.     }  
  20.     protected void RadGrid1_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)  
  21.     {  
  22.         LogDailyLogDataListing();  
  23.     }  
  24.   
  25.     protected void RadGrid1_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs e)  
  26.     {  
  27.         LogDailyLogDataListing();  
  28.     }  
  29.   
  30.     protected void RadGrid1_SortCommand(object sender, Telerik.Web.UI.GridSortCommandEventArgs e)  
  31.     {  
  32.         LogDailyLogDataListing();  
  33.     }  
I will appriciate the help and sample code very much. 
 
Thanks 

Answers (3)