Hello,
I am having difficulty with the problem of accessing the Selected value of a programatically created RadGrid. The purpose of this app is to allow a user to select an order from a grid and open a new page with a new grid populated based on the selection of the previous grid. I can't seem to find an example like this in the forums. Most example assume the grid is bound directly, however I am pulling from a programatically created grid. I am new to Telerik controls. I tried using the format code block but it made my code unreadable.
Here is how I create the grid:
<telerik:RadGrid ID="OrdersGrid" runat="server" Skin="WebBlue" CellSpacing="0" GridLines="None"
ClientSettings-Selecting-AllowRowSelect="True">
<ClientSettings>
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView DataKeyNames="OrderID" ClientDataKeyNames="OrderID">
<CommandItemSettings ExportToPdfText="Export to PDF" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_WebBlue">
</HeaderContextMenu>
</telerik:RadGrid> <telerik:RadGrid ID="OrdersGrid" runat="server" Skin="WebBlue" CellSpacing="0" GridLines="None"
ClientSettings-Selecting-AllowRowSelect="True">
<ClientSettings>
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView DataKeyNames="OrderID" ClientDataKeyNames="OrderID">
<CommandItemSettings ExportToPdfText="Export to PDF" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_WebBlue">
</HeaderContextMenu>
</telerik:RadGrid>
Here is how I bind the data to the new grid:
protected void Page_Load(object sender, EventArgs e)
{
using (Dbcontext)
{
companyID = Convert.ToInt32(Request.QueryString["CompanyID"]);
OrdersGrid.DataSource = Dbcontext.usp_SelectOrders(null,companyID);
OrdersGrid.DataBind();
OrdersGrid.MasterTableView.DataKeyNames = new String[] { "OrderID" };
}
}
Here is how I am attempting to access the SelectedValue of the OrdersGrid:
protected void OrderDetailsButton_Click(object sender, EventArgs e)
{
Response.Redirect("~/Pages/OrderDetails.aspx?OrderID=" + OrdersGrid.SelectedValue.ToString());
}
When the button is clicked I get an error stating that the Selected value has not been initialized. When I hover over the SelectedValue in Debugging mode it says it is "null."
Any thoughts?
Thanks in advance,
Jonathan
I am having difficulty with the problem of accessing the Selected value of a programatically created RadGrid. The purpose of this app is to allow a user to select an order from a grid and open a new page with a new grid populated based on the selection of the previous grid. I can't seem to find an example like this in the forums. Most example assume the grid is bound directly, however I am pulling from a programatically created grid. I am new to Telerik controls. I tried using the format code block but it made my code unreadable.
Here is how I create the grid:
ClientSettings-Selecting-AllowRowSelect="True">
<ClientSettings>
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView DataKeyNames="OrderID" ClientDataKeyNames="OrderID">
<CommandItemSettings ExportToPdfText="Export to PDF" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_WebBlue">
</HeaderContextMenu>
</telerik:RadGrid> <telerik:RadGrid ID="OrdersGrid" runat="server" Skin="WebBlue" CellSpacing="0" GridLines="None"
ClientSettings-Selecting-AllowRowSelect="True">
<ClientSettings>
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView DataKeyNames="OrderID" ClientDataKeyNames="OrderID">
<CommandItemSettings ExportToPdfText="Export to PDF" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_WebBlue">
</HeaderContextMenu>
</telerik:RadGrid>
Here is how I bind the data to the new grid:
protected void Page_Load(object sender, EventArgs e)
{
using (Dbcontext)
{
companyID = Convert.ToInt32(Request.QueryString["CompanyID"]);
OrdersGrid.DataSource = Dbcontext.usp_SelectOrders(null,companyID);
OrdersGrid.DataBind();
OrdersGrid.MasterTableView.DataKeyNames = new String[] { "OrderID" };
}
}
Here is how I am attempting to access the SelectedValue of the OrdersGrid:
protected void OrderDetailsButton_Click(object sender, EventArgs e)
{
Response.Redirect("~/Pages/OrderDetails.aspx?OrderID=" + OrdersGrid.SelectedValue.ToString());
}
When the button is clicked I get an error stating that the Selected value has not been initialized. When I hover over the SelectedValue in Debugging mode it says it is "null."
Any thoughts?
Thanks in advance,
Jonathan