Skip to content

Replies

0
Grace
Grace answered on May 6, 2008 6:42 PM

Hi Nixfon1234,

 In the initializeLayout event, i think it is correct. But what I would recommend is instead of add in this checkbox column during run time, add it in through the design this way you'll know for sure that it is there then once everything is working, then you can switch it over to adding in the checkbox at runtime. All of the property for the checkbox, you can assign it during the design as well.

So, from the code that you listed above, you are trying to capture the checkbox value during the Button1_Click event right??

Just so you know that I developed my code in C# so the code that I gave you in 2 posting ago is exactly what I use in my code and I'm not familiar with the Infragistics syntax in VB.Net but I assumed that they are pretty close.

 So, I am going to do this one line at a time using my code and the sample code you provided.

 

VB: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

C#: Protected void Button1_Click(object sender, EventArgs e){

Dim blnStatus As Boolean = False

Dim SelRow As String

Dim dgdRow As Infragistics.WebUI.UltraWebGrid.UltraGridRow

VB: For Each dgdRow In StatusGrid.Rows

C#: foreach(UltraGridRow row in Ultrawebgrid1){

VB: SelRow = dgdRow.Cells.FromKey("CheckBox").Value.ToString() C#: sChecked  = row.Cells.FromKey("CheckBox").Value.ToString();

Next

End Sub

}

Can you create a brand new .aspx page, throw an ultrawebgrid on and create two columns, col1, col2 – set this one as a CheckBox column. Please do all of this during the design rather than runtime. Then bind some data to col1 so that way for each row of data for col1, it has a checkbox.  In my checkbox, I have AllowUpdate = Yes, Type = CheckBox, DataType = System.String, Key = CheckBox1

Add a button on the screen and give it an event of Button1_Click event and add the foreach loop into the Button1_Click event method. During runtime, select (check) on checkbox for a row, then click Button1 and then slowly step it through to see if you can see the value.

If you convert my C# into VB.Net, it should work fine and the row that you have checked should now be true and the rows that you don't have the checkboxes checked, should be false. The foreach loop should loop through each row on the webgrid. If you want to know what row you are viewing the value, you can set the value the row.Index property inside the for loop.

 From your code and what I have seen, there is nothing wrong with your code.

 Good luck and let me know how it goes!!!

 HS2

0
Grace
Grace answered on May 5, 2008 3:12 PM

Hello Nixfon1234,

First of all, are you using a templated column to add in an asp:CheckBox control or do you use the built-in Infragistics one.  Currently and base on the posting, I am using the built-in Infragisitics checkbox and on the Save button event (asp:Button control event), I do this to get the value whether the checkbox is checked or not: Note that, on the Save button event, I don't know how many rows on the webgrid that I have had the check boxes so i have to use a foreach loop.

1.

 foreach( UltraGridRow row in Ultrawebgrid1.Rows)

{

    string sChecked = row.Cells.FromKey("checkboxcolumnName").Value.ToString();  // I prefer to get my value from the check box to a string rather than a boolean, so you could easily changed the datatype to a boolean if you like.

}

 

2. If you were to try to get the value of a check box from a particular row that you know already and you only select that one row, then you could do this:

string sChecked = Ultrawebgrid1.Displayout.ActiveRow.Cells.FromKey("checkboxcolumnName").Value.ToString();

 I hope it helps. If you need more help, then let me know what your situation is.

 HS2.

 

0
Grace
Grace answered on Jan 10, 2008 6:46 PM

Hello Colette,

Thanks so much!! It worked!  I can't believe that was all I missed!

 Take care and happy coding!!

 hs2

0
Grace
Grace answered on Jan 10, 2008 2:08 PM

Hi Charuk,

 Yep, I tried that the case you suggested above already. But still doesn't work. It seems like it doesn't know that my checkbox even exist.  I have no idea why and that's why it keeps on return false.  I wish the Infragistic experts would give me an example of exactly how to use checkbox on the server side. I want to be able to get the checkbox state on the server side so I can update the database so that way it use a service to send out email to customers.  I think I might have a post a new question in order to get their attention.  I see alot of people having problem with checkboxes. Alot of people are posting the same sort of question as me but getting no answer.

Thanks Charuk for all of your help.  I really appreciate that!!!  If you see anything or have any suggestion, I would love to if you can forward it to.

 hs2

0
Grace
Grace answered on Jan 9, 2008 5:45 PM

Hello Charuk,

Below is the sample code of how I created my checkbox.

<igtbl:UltraGridColumn AllowUpdate="Yes" BaseColumnName="SendEmail" DataType="System.Boolean"
                                    EditorControlID="cbSendEmail" Key="SendEmail" NullText="" Type="CheckBox">
                                    <Header Caption="Send Email">
                                        <RowLayoutColumnInfo OriginX="7" />
                                    </Header>
                                    <Footer>
                                        <RowLayoutColumnInfo OriginX="7" />
                                    </Footer>
                                </igtbl:UltraGridColumn>

protected void BtnSave_Click(object sender, EventArgs e)
        {
         

            foreach (UltraGridRow row in ultrawebgrid1.Rows)
            {
                string sTest = row.Cells[0].Value.ToString();
                //string sChecked = row.Cells.FromKey("SendEmail").Value.ToString();
                string sChecked = row.Cells[7].Value.ToString().ToLower();
                //string sChecked = row.Cells.FromKey("SendEmail").Value.ToString().ToLower();

                if (sChecked.Equals("true"))
                {

                }
            }
 }

I check the checkbox on the actual web page. I don't check the checkbox in the code behind.  In the code behind, I only try to find the checkbox state (which it should return me the state of "true"). 

 Thanks alot in advance!

HS2

0
Grace
Grace answered on Jan 8, 2008 5:39 PM

Hello,

 If you happen to figure out how to retrieve the checkbox value please let me know as well. I have an ultrawebgrid that has a column that uses the checkbox, so when the user checkes the checkbox, I would like to find out the state of it. As of right now, it always return false as if I haven't check the box yet but in reality I did check the checkbox and click the Save button but it still return "false"

 Thanks in advance!

hs2

0
Grace
Grace answered on Jan 8, 2008 5:11 PM

Hello Charuk.,

 i copied and pasted your code into my Save button event method and tried it out, it still gives me the status of False even though the check box is checked. I even hardcoded the column name and columnindex just to test out but still doesn't work. Can you be more specific with the example like include the Save button click event and how you also add the checkbox column in the html side?  I am not sure what I miss that it doesn't work.

THanks alot in advance!

 HS2