Greetings,
My Scenario is as follows,I have a RadCombobox which contains two items
1.Select (value=0)
2.Office(value=1)
On pageload every theing is working fine ie grid is loading when office is selected .The problem is that when combobox item "select" is chosen the grid is again loading.i want to show the grid as null as in the page load.
According to my point of view the problem is NeedDataSource event is not calling except from PageLoad.
Pls help me to solve the issue. Here is my code
private void fill_Grid()
{
clsCheckListMaster chklstmaster = new clsCheckListMaster();
ds = chklstmaster.get_CommodityInInventry(Convert.ToInt32(cmbbxOffice.SelectedValue));
ViewState["ds"] = ds;
if (ds.Tables[0].Rows.Count > 0)
{
gdCheckListMaster.DataSource = ViewState["ds"];
// gdCheckListMaster.DataBind();
}
}
protected void gdCheckListMaster_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if (cmbbxOffice.SelectedIndex > 0)
{
fill_Grid();
gdCheckListMaster.DataSource =ViewState["ds"];
}
else
{
ViewState["ds"] = null;
}
}
protected void gdCheckListMaster_PreRender(object sender, EventArgs e)
{
if (cmbbxOffice.SelectedIndex > 0)
{
gdCheckListMaster.Rebind();
clsCheckListMaster chklstmaster = new clsCheckListMaster();
for (int i = 0; i < gdCheckListMaster.Items.Count; i++)
{
CheckBox chkbxDaily = (CheckBox)gdCheckListMaster.Items[i].FindControl("chkbxDaily");
CheckBox chkbxWeekly = (CheckBox)gdCheckListMaster.Items[i].FindControl("chkbxWeekly");
CheckBox chkbxYearly = (CheckBox)gdCheckListMaster.Items[i].FindControl("chkbxYearly");
DataSet ds1 = chklstmaster.getDetails_ChklstmsterANDRtlcmdtylst();
if (ds1.Tables[0].Rows.Count > 0)
{
for (int j = 0; j < ds1.Tables[0].Rows.Count; j++)
{
if (int.Parse(gdCheckListMaster.Items[i][gdCheckListMaster.Columns[0]].Text) == int.Parse(ds1.Tables[0].Rows[j]["INTERNALCOMMODITYID"].ToString()))
{
if (int.Parse(ds1.Tables[0].Rows[j]["DAILY"].ToString()) == 1)
{
chkbxDaily.Checked = true;
chkbxDaily.Enabled = false;
}
if (int.Parse(ds1.Tables[0].Rows[j]["WEEKLY"].ToString()) == 1)
{
chkbxWeekly.Enabled = false;
chkbxWeekly.Checked = true;
}
if (int.Parse(ds1.Tables[0].Rows[j]["YEARLY"].ToString()) == 1)
{
chkbxYearly.Enabled = false;
chkbxYearly.Checked = true;
}
}
}
}
}
}
else
{
ViewState["ds"] = null;
}
My Scenario is as follows,I have a RadCombobox which contains two items
1.Select (value=0)
2.Office(value=1)
On pageload every theing is working fine ie grid is loading when office is selected .The problem is that when combobox item "select" is chosen the grid is again loading.i want to show the grid as null as in the page load.
According to my point of view the problem is NeedDataSource event is not calling except from PageLoad.
Pls help me to solve the issue. Here is my code
private void fill_Grid()
{
clsCheckListMaster chklstmaster = new clsCheckListMaster();
ds = chklstmaster.get_CommodityInInventry(Convert.ToInt32(cmbbxOffice.SelectedValue));
ViewState["ds"] = ds;
if (ds.Tables[0].Rows.Count > 0)
{
gdCheckListMaster.DataSource = ViewState["ds"];
// gdCheckListMaster.DataBind();
}
}
protected void gdCheckListMaster_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if (cmbbxOffice.SelectedIndex > 0)
{
fill_Grid();
gdCheckListMaster.DataSource =ViewState["ds"];
}
else
{
ViewState["ds"] = null;
}
}
protected void gdCheckListMaster_PreRender(object sender, EventArgs e)
{
if (cmbbxOffice.SelectedIndex > 0)
{
gdCheckListMaster.Rebind();
clsCheckListMaster chklstmaster = new clsCheckListMaster();
for (int i = 0; i < gdCheckListMaster.Items.Count; i++)
{
CheckBox chkbxDaily = (CheckBox)gdCheckListMaster.Items[i].FindControl("chkbxDaily");
CheckBox chkbxWeekly = (CheckBox)gdCheckListMaster.Items[i].FindControl("chkbxWeekly");
CheckBox chkbxYearly = (CheckBox)gdCheckListMaster.Items[i].FindControl("chkbxYearly");
DataSet ds1 = chklstmaster.getDetails_ChklstmsterANDRtlcmdtylst();
if (ds1.Tables[0].Rows.Count > 0)
{
for (int j = 0; j < ds1.Tables[0].Rows.Count; j++)
{
if (int.Parse(gdCheckListMaster.Items[i][gdCheckListMaster.Columns[0]].Text) == int.Parse(ds1.Tables[0].Rows[j]["INTERNALCOMMODITYID"].ToString()))
{
if (int.Parse(ds1.Tables[0].Rows[j]["DAILY"].ToString()) == 1)
{
chkbxDaily.Checked = true;
chkbxDaily.Enabled = false;
}
if (int.Parse(ds1.Tables[0].Rows[j]["WEEKLY"].ToString()) == 1)
{
chkbxWeekly.Enabled = false;
chkbxWeekly.Checked = true;
}
if (int.Parse(ds1.Tables[0].Rows[j]["YEARLY"].ToString()) == 1)
{
chkbxYearly.Enabled = false;
chkbxYearly.Checked = true;
}
}
}
}
}
}
else
{
ViewState["ds"] = null;
}