Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
Retrieving checked rows from code behind
posted

Hi,

I am new to using infragistics webgrid in asp .net. I have two webgrids, the first one binds a list of users from the database. It has a checkbox as the first column. A user can select the checkbox and hit add button on the bottom. Then, the bottom grid would populate the selected rows. This is what I have done:

 

 

<ig:WebDataGrid ClientIDMode="Predictable" ID="searchGrid" runat="server"

                        Width="100%" AutoGenerateColumns="False" BorderColor="#CCCCCC" EnableDataViewState="True" EnableAjax="false">

                        <Columns>

                            <ig:TemplateDataField Key="UserLoginName" Width="150px">

                                <ItemTemplate>

                                    <asp:CheckBox ID="chkPlan" Key="UserLoginName" runat="server" />

                                </ItemTemplate>

                                <Header TemplateId="chkPlan" />

                            </ig:TemplateDataField>

                            <ig:BoundDataField DataFieldName="UserID" Key="UserId" Width="100px">

                                <Header Text="User Id" CssClass="igg_HeaderCaptionSort" ></Header>

                            </ig:BoundDataField>

                            <ig:BoundDataField DataFieldName="FirstName" Key="UserFirstName" Width="100px">

                                <Header Text="First Name" CssClass="igg_HeaderCaptionSort" ></Header>

                            </ig:BoundDataField>

                            <ig:BoundDataField DataFieldName="LastName" Key="UserLastName" Width="130px">

                                <Header Text="Last Name" CssClass="igg_HeaderCaptionSort"></Header>

                            </ig:BoundDataField>                            

                            <ig:BoundDataField DataFieldName="RoleName" Key="RoleName" Width="131px">

                                <Header Text="Role"></Header>

                            </ig:BoundDataField>

                            <ig:BoundDataField DataFieldName="DepartmentName" Key="Department" Width="131px">

                                <Header Text="Department"></Header>

                            </ig:BoundDataField>                            

                        </Columns>

                        <Behaviors>

                            <ig:Sorting>

                                <ColumnSettings>

                                    <ig:SortingColumnSetting ColumnKey="UserId" Sortable="false" />

                                    <ig:SortingColumnSetting ColumnKey="UserFirstName" Sortable="true" />

                                    <ig:SortingColumnSetting ColumnKey="UserLastName" />                                   

                                    <ig:SortingColumnSetting ColumnKey="RoleName" Sortable="False" />

                                    <ig:SortingColumnSetting ColumnKey="Department" Sortable="False" />

                                </ColumnSettings>

                            </ig:Sorting>

                        </Behaviors>

                    </ig:WebDataGrid>

 

 

The above webgrid is populated with data from the database. Now in the code behind I'm trying something like this.

 

       protected void btnAdd_Click(object sender, EventArgs e)

        {

            foreach (GridRecord item in searchGrid.Rows)

            {

                if ((item.FindControl("chkPlan") as CheckBox).Checked)

                {

                    //bind the bottom grid

                }

            }

        }

 

 

But when i try debugging, searchGrid.Rows is empty.But the screen has this grid populated already.

Parents
  • 49378
    posted

    Hi niranjansnair,

    Thank you for posting in the community.

    I assume that you are assigning the grid's datasource in the Page_Load handler, however can you please also ensure that you call DataBind() on the grid in that stage in order to ensure that the data is rebound in time to be accessible when handling the button click.

    Please let me know if this helps.  

Reply Children
No Data