Skip to content

Infragistics Community Forum / Cross Platform / Ultimate UI for Xamarin / loop on WebGrid find check box true or false

loop on WebGrid find check box true or false

New Discussion
aka kumar
aka kumar asked on Jan 14, 2022 10:25 PM

i am not found ig:TemplateDataField   <asp:CheckBox ID=”CheckBox2″ runat=”server” ClientIDMode=”AutoID” />

value =1 or 0 or true or false.

Please  help me .

foreach (GridRecord row in listWebGrid.Rows)

{

string itm = row.Items[0].text;

}

please help as soon as possible.

thanks

Sign In to post a reply

Replies

  • 0
    aka kumar
    aka kumar answered on Oct 12, 2015 4:55 AM

    i want to check server side to save value in db

    • 0
      Ivaylo Ganchev
      Ivaylo Ganchev answered on Oct 12, 2015 1:07 PM

      The following threads contain most of the possible case scenarios with the use of CheckBox fields in WDG. Please notice, some of the forum threads have samples attachments available as well: 

      Capture checkbox checkedchange event from webdatagrid template coloumn
      Checkbox in WebDataGrid
      – Or using ig:BoundCheckBoxField as for example 

      – In case you are using EditTemplate

      -What is more, in case you could use the unbound column in you app, you could consider the use of checkboxes with Boolean values as implemented 

      I believe the above will help you achieve your requirements.

       

      • 0
        aka kumar
        aka kumar answered on Oct 12, 2015 1:46 PM

        thnaks for support but 

        in want to find template column on value  for each loop to save multiple value on server side 

        if check box is check then save values.

        check box have two or more check box checked on grid  option 

        1 -checkbox1 =check

        2 -checkbox1=check

        i want to save two rows value.

        foreach (GridRecord row in listWebGrid.Rows)

        {

        string itm = row.Items[0].text;

        }

      • 0
        Ivaylo Ganchev
        Ivaylo Ganchev answered on Oct 13, 2015 10:17 AM

        Hello,

        It is not clear for me how many CheckBoxes you are using. string itm = row.Items[0].text will not return what you would expect.

        However, if what you would like to get is the checked status of the checkBoxes when using  TemplateDataField and ItemTemplate, you could find these template controls at the server using the following approach. You could use the checkBox.Checked status and set the values in the DB as true-false, 0-1 or 1-2 or else based on the logic required.
        Lets say you have the following markup

        <ig:TemplateDataField Key="Asd">
           <ItemTemplate>
        <asp:CheckBox runat="server" ID="CheckBox1" Checked="true" OnCheckedChanged="CheckBox1_CheckedChanged" AutoPostBack="true"  ClientIDMode="AutoID"/>               </ItemTemplate>
        /ig:TemplateDataField>

        And in code behind you could access all checkboxes iterating each row and find the checked status:

        if (IsPostBack)

                {    
                    foreach (GridRecord row in WebDataGrid1.Rows)

                    {
                        CheckBox checkBox= (CheckBox)row.Items.FindItemByKey("Asd").FindControl("CheckBox1");
                        bool isChecked = checkBox.Checked;
                    } 
                } 

        In case you would like to do PostBack immediately after a checkbox status is changed/clicked, you could handle OnCheckedChanged="CheckBox1_CheckedChanged for example.
            protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
            {
                CheckBox checkBox = (CheckBox)sender;
                bool isChecked = checkBox.Checked;
            }

      • 0
        Robert  Lassen
        Robert Lassen answered on Oct 13, 2015 2:00 PM

        I think  u do't know about EnsureTemplates without call of this method, we never find any template field  check box  

        listWebGrid.DataSource = ((DataTable)ViewState["voidCertDataSet"]);
        listWebGrid.EnsureTemplates();

        by 

         CheckBox chkbx = row.Items[0].FindControl("IsSelected") as CheckBox;

        ok fine for help 

        this is solution.

      • 0
        chandu raj
        chandu raj answered on Jan 14, 2022 10:25 PM

        Hey, i have same exact code on the page, is not returning any value for the checkbox or returning null for  this

        design page:

        <IGGC:TemplateDataField Header-Text="" Width="30" Key="Asd">
        <ItemTemplate>
        <asp:CheckBox CssClass="tac" ID="CheckBox1" runat="server" AutoPostBack="True" />
        </ItemTemplate>

        checking this code:

        CheckBox cb = (CheckBox)gr.Items.FindItemByKey("Asd").FindControl("CheckBox1");

        this is returning null value, any idea or input please?

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
aka kumar
Favorites
0
Replies
6
Created On
Jan 14, 2022
Last Post
4 years, 1 month ago

Suggested Discussions

Created by

Created on

Jan 14, 2022 10:25 PM

Last activity on

Feb 19, 2026 8:56 PM