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.
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
Hi Hs2,
I was able to figure out how to store the values of the checkboxes but it was kinda tricky. Since I had multiple pages in the gridview and would lose the selected options when I went to the next page because of post back I ended up storing the values (any unique item in the row) in an Arraylist. Then I put this arraylist into the view state and retrieved it when the page reloaded with the next results. I did this in the datagrid_pageindexchanged Event.
now Im stuck on trying to edit the column header so I can put a check all checkbox in the Column header. I tried doing:
col.HeaderItem.TemplateControl.Controls.Add(CheckAll)
but this did not work. I need to be able to do this at Runtime and need a way to select/unselect all rows.
Thank you very much for your replay.
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 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!!!
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
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