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
I think you are missing the AllowUpdate="Yes" property. If you try that, it should work. I tried on mine by setting AllowUpdate="No" and the checkbox is disabled and when I set it to "Yes" it's enable again.
HS2
Thanks so much HS2, That worked! :) I wasted so much time yest on this. For anyone else reading this you can enable the webgrid to be updatable if you have a similar problem by changing the AllowUpdate to yes
datagrid.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes
Now I just have to figure out how to store the checked boxes since they lose their value when you go to another page on the grid.
Try this,
Dim blnStatus As Boolean = False
Dim dgdRow As UltraGridRow
For Each dgdRow In dgdLead.Rows If dgdRow.Cells(1).Value = 1 Then blnStatus = True End If Next
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()
col.HeaderText = ""
col.Type = Infragistics.WebUI.UltraWebGrid.ColumnType.CheckBox
col.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes
col.Width = Unit.Pixel(20)
this code working very fine. but for find value for check box its not work. please help me if you have any other solution????
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.
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 = "String"
'col.DataType="Boolean"
'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
Next
waiting for your replay.
I'm not sure, but I think this:
should be
col.DataType = "System.Boolean"
Let me know if that works
I already solved the problem. im loading grid data in page load and i forget to put is post back = false.
Thanks for giving your suggetion.
Please let me know if you have any javascript function which i can use with web grid. like click event., double click event, hide control, visible control.
How can i open dialog window box when i click on web grid? please provide if you have any javascript code.
thank you very much in advance
have a nice day
Hello HS2,
Thank you very much for your wonderfull support. You gave me better support then infragisitc support. I really appriciate.
I already able to solved that problem and now my code working very nice. Im Really happy for it. Thanks again.
Your first code working fine but because of my mistake (Forget to put page.ispostback =false in load time so every time datagrid have new source so old data is loossing).
If you dont mine i also have another issue if you have time then please let me know the answer for that. i already ask to infragisitc and then gave me answer but im not happy with it. this one is not so urgent so take your time no problem.
Quetion 1:
I have web dialog window, i want to hide and show in button click. but i want to use javascript code. i dont know how can i call javascript code from ASP.net code. not in html i want to call from .vb page.
Please provide me the function in java script to hide and show dialog window.
Please provide example code how can i call that function from .vb page.
Quetion 2:
I have web grid how can i get record in text box when i click. i have vb code but im looking for javascript code so page will not refresh on everyclick.
This is my Code what im using now planing to use javascript for it.
If e.Row Is Nothing = False Then
ID.Text = e.Row.Cells(0).GetText.ToString 'id
cmbDelegateTo.SelectedValue = e.Row.Cells(1).GetText.ToString 'Delegate Person
cmbDepartment.SelectedValue = e.Row.Cells(2).GetText.ToString 'Department
cmbDivision.SelectedValue = e.Row.Cells(3).GetText.ToString 'Division
txtStartDate.Value = e.Row.Cells(4).GetText.ToString 'StartDate
txtEndDate1.Value = e.Row.Cells(5).GetText.ToString 'End date
txtComment.Text = e.Row.Cells(6).GetText.ToString 'comments
btnEdit.Enabled = True
btnDelete.Enabled = True
e.Row.Selected = True
Else
btnEdit.Enabled = False
btnDelete.Enabled = False
Thank you very much again for your help.
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 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()
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!!!