DATAGRID template column problem
-
Hi guys/ gals, I am working on ASP.NET 2.0. I have careted a datagrid in which ihave around 3 template columns each containing Checkboxes. I want to update the record based on that checkboxes. Like if there are three columns with name Status, Permissions, Active. so when i click the checkbox of the first row of status it should only change the status of that particular record in db with that status. I am confused how I can do it. plss reply me urgently... If anybody can help me with the code..that will be great.. Please help me.. KHATRI
-
Hi guys/ gals, I am working on ASP.NET 2.0. I have careted a datagrid in which ihave around 3 template columns each containing Checkboxes. I want to update the record based on that checkboxes. Like if there are three columns with name Status, Permissions, Active. so when i click the checkbox of the first row of status it should only change the status of that particular record in db with that status. I am confused how I can do it. plss reply me urgently... If anybody can help me with the code..that will be great.. Please help me.. KHATRI
-
When are you trying to updated the database? Suppose if the button is outside datagrid then you need to loopthrough all the items and find the checkbox and then depending on the selection status you can update the database.
Best Regards, Apurva Kaushal
It is inside the datagrid. Its placed in the template column of the datagrid.. KHATRI
-
It is inside the datagrid. Its placed in the template column of the datagrid.. KHATRI
-
In that case you can use OnItemCommand event of the datagrid. whenever you will click the button that event will get fired and there you can execute your storedprocedure to update the record.
Best Regards, Apurva Kaushal
WEll i tried with ItemCommand Event of the Datagrid but its not working. Because I am not able to define a command with that Checkbox so to match with the Command inorder to process with the checkbox. Can i have ur personal msn id..? so ill explain you by sending you a picture.. if you can help me..? KHATRI
-
WEll i tried with ItemCommand Event of the Datagrid but its not working. Because I am not able to define a command with that Checkbox so to match with the Command inorder to process with the checkbox. Can i have ur personal msn id..? so ill explain you by sending you a picture.. if you can help me..? KHATRI
What you want to do is whenever user checks the checkbox you want to fire the event and update the database, if this is your case then it won't be a good idea. Inspite of that you can put a button and on click event of that button you can loop through all the items and check which one has been checked and those will be updated to the database.
Best Regards, Apurva Kaushal
-
Hi guys/ gals, I am working on ASP.NET 2.0. I have careted a datagrid in which ihave around 3 template columns each containing Checkboxes. I want to update the record based on that checkboxes. Like if there are three columns with name Status, Permissions, Active. so when i click the checkbox of the first row of status it should only change the status of that particular record in db with that status. I am confused how I can do it. plss reply me urgently... If anybody can help me with the code..that will be great.. Please help me.. KHATRI
Hi Faisal, Here i have listed some steps according to your requirement. Hope this will be helpful. 1. Modify your template column in the datagrid as below in the design/source view. 2.In the Vb code file, Create a Procedure which be called when the checkbox state is changed. Private Sub OnStatusChangedEvent(ByVal sender As Object, ByVal e As System.EventArgs) Dim cboxStatus As CheckBox Dim dGrid As DataGridItem cboxStatus= CType(sender, CheckBox) 'This will inherit the datagrid template checkbox propeties which you have clicked dGrid = CType(cboxStatus.NamingContainer, DataGridItem) 'If you need to find the text value in any datagrid column for ex. ID then Dim id as integer=dGrid.Cells(0).Text 'Here id is the first column in the datagrid for your example If cboxStatus.Checked = True Then 'Do the sql insert/update here by passing the id. End If End Sub This will be useful only when you want to update a row by changing the Checbox state in the template. Otherwise if you need to update multiple row you have to loop through all rows and write a procedure in a button click event(When you use button click event set autopostback="false" in the checkbox). Regards, Raghu -- modified at 4:54 Friday 27th April, 2007