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)
- <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" DataSourceID="SqlDataSource2" AllowSorting="True"
- PageSize="7" AllowPaging="True" runat="server" OnSortCommand="RadGrid1_SortCommand"
- OnPageIndexChanged="RadGrid1_PageIndexChanged" OnPageSizeChanged="RadGrid1_PageSizeChanged" OnEditCommand="RadGrid1_EditCommand">
- <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
- <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataSourceID="SqlDataSource2"
- DataKeyNames="logId" AutoGenerateColumns="false" InsertItemDisplay="Top"
- InsertItemPageIndexAction="ShowItemOnFirstPage">
- <Columns>
- <telerik:GridButtonColumn DataTextField="logId" CommandName="Edit">
- </telerik:GridButtonColumn>
- <telerik:GridBoundColumn DataField="log_date" UniqueName="log_date" HeaderText="Date">
- </telerik:GridBoundColumn>
- <telerik:GridBoundColumn DataField="log_type" UniqueName="log_type" HeaderText="Type">
- </telerik:GridBoundColumn>
- <telerik:GridBoundColumn DataField="client_name" UniqueName="client_name" HeaderText="Client Name">
- </telerik:GridBoundColumn>
- <telerik:GridBoundColumn DataField="delivery_method" UniqueName="delivery_method" HeaderText="Method">
- </telerik:GridBoundColumn>
- <telerik:GridBoundColumn DataField="entered_by" UniqueName="entered_by" HeaderText="Entered By">
- </telerik:GridBoundColumn>
- <telerik:GridBoundColumn DataField="facility_name" UniqueName="facility_name" HeaderText="Facility">
- </telerik:GridBoundColumn>
- <telerik:GridBoundColumn DataField="log_status" UniqueName="log_status" HeaderText="Status">
- </telerik:GridBoundColumn>
- <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
- </telerik:GridButtonColumn>
- </Columns>
- </MasterTableView>
-
- </telerik:RadGrid>
- <asp:SqlDataSource ID="SqlDataSource2" runat="server"></asp:SqlDataSource>
default.aspx.cs (Code behind)
- protected void LogDailyLogDataListing()
- {
-
- SqlDataSource2.ConnectionString = "Connection String Here"
- SqlDataSource2.SelectCommand = "select * from table";
- this.RadGrid1.DataBind();
- }
- protected void RadGrid1_EditCommand(object sender, EventArgs e)
- {
-
- foreach (var item in RadGrid1.SelectedItems)
- {
- if (item is GridDataItem)
- {
- GridDataItem dataItem = item as GridDataItem;
- string sLogId = dataItem["logId"];
- }
- }
- }
- protected void RadGrid1_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
- {
- LogDailyLogDataListing();
- }
-
- protected void RadGrid1_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs e)
- {
- LogDailyLogDataListing();
- }
-
- protected void RadGrid1_SortCommand(object sender, Telerik.Web.UI.GridSortCommandEventArgs e)
- {
- LogDailyLogDataListing();
- }
I will appriciate the help and sample code very much.
Thanks