My problem is that when i move from radgrid page1 to page 2 DataBound event is not calling,where i have written my necessary code.
protected void gdTools_DataBound(object sender, EventArgs e)
{
clsVehicleToolMaping vhcleToolMapping = new clsVehicleToolMaping();
//get all tools from inventory
DataSet ds = vhcleToolMapping.get_ToolsforMapping(int.Parse(cmbbxOffice.SelectedItem.Value));
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
//get all tools from ToolMapping
DataSet ds2 = vhcleToolMapping.get_DetailsfromToolsMapping(int.Parse(ds.Tables[0].Rows[i]["SPECPARTNOID"].ToString()));
for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
{
int vrno = int.Parse(cmbbxVrnno.SelectedItem.Value);
if (vrno == int.Parse(ds2.Tables[0].Rows[j]["INTERNALVRNNO"].ToString()))
{
for (int k = 0; k < gdTools.Items.Count; k++)
{
if ((gdTools.Items[k][gdTools.Columns[0]].Text) == (ds.Tables[0].Rows[i]["SPECPARTNOID"].ToString()))
{
CheckBox cb = (CheckBox)gdTools.Items[k][gdTools.Columns[2]].FindControl("chkbxStatus");
cb.Enabled = false;
cb.Checked = true;
}
}
}
}
}
}
private void fill_grid()
{
clsVehicleToolMaping vhcleToolMapping = new clsVehicleToolMaping();
ds = vhcleToolMapping.get_ToolsforMapping(int.Parse(cmbbxOffice.SelectedItem.Value));
if (ds.Tables[0].Rows.Count > 0)
{
gdTools.DataSource = ds;
}
}
protected void gdTools_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if (cmbbxVrnno.SelectedIndex > 0)
{
fill_grid();
this.gdTools.DataSource = this.ds;
}
}
--------------------------------------
This is my Radgrid designer
----------------------------------------
<telerik:RadGrid ID="gdTools" runat="server" AllowMultiRowSelection="true" Skin="Vista"
AllowPaging="true" PageSize="1" AutoGenerateColumns="false"
onneeddatasource="gdTools_NeedDataSource"
onitemdatabound="gdTools_ItemDataBound" ondatabound="gdTools_DataBound">
<MasterTableView >
<Columns>
<telerik:GridBoundColumn UniqueName="SPECPARTNOID" SortExpression="SPECPARTNOID"
HeaderText="SPECPARTNOID" DataField="SPECPARTNOID" ReadOnly="true" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="COMMODITY" SortExpression="COMMODITY"
HeaderText="COMMODITY" DataField="COMMODITY" ReadOnly="true" >
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Status" UniqueName="MyTemplateColumn">
<ItemTemplate>
<asp:CheckBox id="chkbxStatus" runat="server" >
</asp:CheckBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
i have tried the databound event code in item_databound event but the problem is that
for (int k = 0; k < gdTools.Items.Count; k++)
when the control goes to the above code count is always shown as zero.so events are not happening that are inside the for loop
protected void gdTools_DataBound(object sender, EventArgs e)
{
clsVehicleToolMaping vhcleToolMapping = new clsVehicleToolMaping();
//get all tools from inventory
DataSet ds = vhcleToolMapping.get_ToolsforMapping(int.Parse(cmbbxOffice.SelectedItem.Value));
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
//get all tools from ToolMapping
DataSet ds2 = vhcleToolMapping.get_DetailsfromToolsMapping(int.Parse(ds.Tables[0].Rows[i]["SPECPARTNOID"].ToString()));
for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
{
int vrno = int.Parse(cmbbxVrnno.SelectedItem.Value);
if (vrno == int.Parse(ds2.Tables[0].Rows[j]["INTERNALVRNNO"].ToString()))
{
for (int k = 0; k < gdTools.Items.Count; k++)
{
if ((gdTools.Items[k][gdTools.Columns[0]].Text) == (ds.Tables[0].Rows[i]["SPECPARTNOID"].ToString()))
{
CheckBox cb = (CheckBox)gdTools.Items[k][gdTools.Columns[2]].FindControl("chkbxStatus");
cb.Enabled = false;
cb.Checked = true;
}
}
}
}
}
}
private void fill_grid()
{
clsVehicleToolMaping vhcleToolMapping = new clsVehicleToolMaping();
ds = vhcleToolMapping.get_ToolsforMapping(int.Parse(cmbbxOffice.SelectedItem.Value));
if (ds.Tables[0].Rows.Count > 0)
{
gdTools.DataSource = ds;
}
}
protected void gdTools_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if (cmbbxVrnno.SelectedIndex > 0)
{
fill_grid();
this.gdTools.DataSource = this.ds;
}
}
--------------------------------------
This is my Radgrid designer
----------------------------------------
<telerik:RadGrid ID="gdTools" runat="server" AllowMultiRowSelection="true" Skin="Vista"
AllowPaging="true" PageSize="1" AutoGenerateColumns="false"
onneeddatasource="gdTools_NeedDataSource"
onitemdatabound="gdTools_ItemDataBound" ondatabound="gdTools_DataBound">
<MasterTableView >
<Columns>
<telerik:GridBoundColumn UniqueName="SPECPARTNOID" SortExpression="SPECPARTNOID"
HeaderText="SPECPARTNOID" DataField="SPECPARTNOID" ReadOnly="true" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="COMMODITY" SortExpression="COMMODITY"
HeaderText="COMMODITY" DataField="COMMODITY" ReadOnly="true" >
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Status" UniqueName="MyTemplateColumn">
<ItemTemplate>
<asp:CheckBox id="chkbxStatus" runat="server" >
</asp:CheckBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
i have tried the databound event code in item_databound event but the problem is that
for (int k = 0; k < gdTools.Items.Count; k++)
when the control goes to the above code count is always shown as zero.so events are not happening that are inside the for loop