This is a migrated thread and some comments may be shown as answers.

Radgrid checkbox problem

1 Answer 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
susha
Top achievements
Rank 1
susha asked on 01 Dec 2010, 12:19 PM
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

        

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 02 Dec 2010, 04:49 PM
Hello susha,

Make sure that you are not data-binding/rebinding the grid at any other point in the page life cycle.

All the best,
Tsvetoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
susha
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or