Hello everyone,
I am using a radGrid to display records of data. I am attempting to implement a RadDropDownList that will alter the displayed data in radGrid based on the value selected. The dropDown list correctly rebinds the data and displays the new set of information. My problem occurs when the user attempts to move to a different page or attempts to sort the information. The grid is rebound to the original dataSource and does not maintain the dropDown selected dataSource. What is the best way to maintain the correct dataSource through page postbacks?
DropDown ASPX:
RadGrid NeedDataSource:
BatchNameSelected (Rebind of DataSource to selected data):
RadGrid PageIndexChanged:
Page_Load:
Question: How do I maintain the selected DataSource through postbacks caused by paging and sorting?
I have been unable to find a solution that pertains to my example and would appreciate any help I can get.
Thanks,
Matt
I am using a radGrid to display records of data. I am attempting to implement a RadDropDownList that will alter the displayed data in radGrid based on the value selected. The dropDown list correctly rebinds the data and displays the new set of information. My problem occurs when the user attempts to move to a different page or attempts to sort the information. The grid is rebound to the original dataSource and does not maintain the dropDown selected dataSource. What is the best way to maintain the correct dataSource through page postbacks?
DropDown ASPX:
<
telerik:RadDropDownList
ID
=
"BatchRadDropDownList"
runat
=
"server"
OnItemSelected
=
"BatchNameSelected"
AutoPostBack
=
"true"
DefaultMessage
=
"- Batch Names -"
>
</
telerik:RadDropDownList
>
RadGrid NeedDataSource:
protected
void
RadGridActionItem_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
// Provides RadGrid with Action Item data.
List<IDataParameter> Parms =
null
;
string
SQL =
string
.Empty;
DataTable dt;
try
{
using
(DataAccess da =
new
DataAccess())
{
SQL = COMPLIANCE_SQL.GET_ALL_NEW_ACTION_ITEMS();
dt = da.GetDataSet(SQL, Parms).Tables[0];
RadGridActionItem.DataSource = dt;
}
}
catch
(Exception ex)
{
throw
ex;
}
}
BatchNameSelected (Rebind of DataSource to selected data):
protected
void
BatchNameSelected(
object
sender, DropDownListEventArgs e)
{
List<IDataParameter> Parms =
null
;
string
SQL =
string
.Empty;
DataTable dt;
try
{
// Query for batch names and bind data to Batch RadDropDownList.
using
(DataAccess da =
new
DataAccess())
{
SQL = COMPLIANCE_SQL.GET_ACTION_ITEM_VIA_BATCH_NAME(
ref
Parms, e.Text);
dt = da.GetDataSet(SQL, Parms).Tables[0];
RadGridActionItem.DataSource = dt;
RadGridActionItem.Rebind();
}
}
catch
(Exception ex)
{
throw
ex;
}
}
RadGrid PageIndexChanged:
protected
void
RadGridActionItem_PageIndexChanged(
object
sender, GridPageChangedEventArgs e)
{
// Allows for RadGrid paging property.
RadGridActionItem.CurrentPageIndex = e.NewPageIndex;
}
Page_Load:
protected
void
Page_Load(
object
sender, EventArgs e)
{
FillBatchDropDown();
}
Question: How do I maintain the selected DataSource through postbacks caused by paging and sorting?
I have been unable to find a solution that pertains to my example and would appreciate any help I can get.
Thanks,
Matt