Protected Sub dgPatients_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles dgPatients.InitializeLayout
If Not Page.IsPostBack Then
col.Key = "CheckBox"
col.HeaderText = "Select Products"
e.Layout.Bands(0).Columns.Insert(0, col)
col.Type = ColumnType.CheckBox
col.IsEditable()
col.Width = Unit.Pixel(50)
End If
End Sub
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 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()
Next
}
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
I'm not sure, but I think this:
col.DataType = "String"
should be
col.DataType = "System.Boolean"
Let me know if that works
Hello HS2
Thank you very much for your replay.
Im using Infragistic check box column. here you can see the code what im using. Im trying this code but every time im getiing "False" value.
Please guid me if im mistaken any place.
Protected Sub StatusGrid_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles StatusGrid.InitializeLayout
'col.DataType="Boolean"
col.HeaderText = ""
col.Type = Infragistics.WebUI.UltraWebGrid.ColumnType.CheckBox
col.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes
col.Width = Unit.Pixel(20)
'Dim ij As Boolean
'For i = 0 To Me.StatusGrid.Rows.Count
' Me.StatusGrid.DisplayLayout.SelectTypeRowDefault = Infragistics.WebUI.UltraWebGrid.SelectType.Single
' ' Select the row
' If Me.StatusGrid.DisplayLayout.Rows(i).Selected = True Then
' ij = StatusGrid.DisplayLayout.Rows(i).Cells(0).GetText.ToString
' End If
'Next
Dim SelRow As String
For Each dgdRow In StatusGrid.Rows
'If dgdRow.Cells(0).Value = 1 Then
'blnStatus = True
waiting for your replay.
Thanking you
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.
Thanks for your very fast replay. I used your code but still i can not get selected checkbox value.
For adding check box column im using this code.
Dim col As New Infragistics.WebUI.UltraWebGrid.UltraGridColumn()
this code working very fine. but for find value for check box its not work. please help me if you have any other solution????