Adding CheckBox in ASP.NET
-
Dear Programmers, I need your help. I am developing a project in ASP.NET in which I am using VB.NET as Language. I want to add CheckBox in DataGrid. Even I am succeded in showing the checkbox in Datagrid but I am unable to give the user opportunity to select the checkboxes. The checkbox field directly checks or unchecks the checkbox by getting data from one of the column of my database. My database is in SQL Server 2000. Please help me. I am also sending the scripting code below. <%@ Page Language="VB" %>
CheckBoxField Example
CheckBoxField Example
please check the code and tell me where i am doing mistake so that i shall correct it. Please Remember that I am using Visual Studio 2005 as an editor to code ASP.NET. If you solve the problem then please inform me on the following ID: zeeshan_st2003@yahoo.com Thankyou. Waiting for your reply. One of your Programmer Friend, Zeeshan Ahmad.
-
Dear Programmers, I need your help. I am developing a project in ASP.NET in which I am using VB.NET as Language. I want to add CheckBox in DataGrid. Even I am succeded in showing the checkbox in Datagrid but I am unable to give the user opportunity to select the checkboxes. The checkbox field directly checks or unchecks the checkbox by getting data from one of the column of my database. My database is in SQL Server 2000. Please help me. I am also sending the scripting code below. <%@ Page Language="VB" %>
CheckBoxField Example
CheckBoxField Example
please check the code and tell me where i am doing mistake so that i shall correct it. Please Remember that I am using Visual Studio 2005 as an editor to code ASP.NET. If you solve the problem then please inform me on the following ID: zeeshan_st2003@yahoo.com Thankyou. Waiting for your reply. One of your Programmer Friend, Zeeshan Ahmad.
Do you need the Checkbox to be dynamically checked or unchecked during databinding ?? Or do you mean you want the checkbox to be fire when user makes a selection in another column in the grid?? For the first, you can attach the value from the datage to the Checked event of the checkbox, so if the value bound is in bit/boolean form from the database, that sets the checked event of the checkbox to false or true. For the second, you can set it in the such a way that when the user makes a selection in the column that determins the value of the state of the checkbox, based on selection, you either check or uncheck the checkbox in your grid
-
Dear Programmers, I need your help. I am developing a project in ASP.NET in which I am using VB.NET as Language. I want to add CheckBox in DataGrid. Even I am succeded in showing the checkbox in Datagrid but I am unable to give the user opportunity to select the checkboxes. The checkbox field directly checks or unchecks the checkbox by getting data from one of the column of my database. My database is in SQL Server 2000. Please help me. I am also sending the scripting code below. <%@ Page Language="VB" %>
CheckBoxField Example
CheckBoxField Example
please check the code and tell me where i am doing mistake so that i shall correct it. Please Remember that I am using Visual Studio 2005 as an editor to code ASP.NET. If you solve the problem then please inform me on the following ID: zeeshan_st2003@yahoo.com Thankyou. Waiting for your reply. One of your Programmer Friend, Zeeshan Ahmad.
Zeeshan Memon wrote:
asp:checkboxfield datafield="contract" text="Contract" headertext="Contract"
Have you read this?
Note from MSDN example
Because a check box can display only a selected or an unselected state, a CheckBoxField object can be bound only to a field with a Boolean data type or a string that can be parsed by Parse.
So, if "contract" field is boolean type then the checkedbox will display a selected or unselected automatically.. If your field is a string type and the data from that column is not "1" or "0" then ~ - Try to change this column to template column - Add one more hidden label in that column and set the datafield of this label to the database field (e.g. "contract") - In Item_bound event, find this label and check/uncheck the checked box accordingly. e.g. Label l = e.FindControl("myhiddenlabel"); CheckedBox c = e.FindControl("chkBoxContract"); if (l.Text == "abc"){ c.Checked = true; } P.S: I wrote this example just like that here without checking in Visual studio.. but you may get some ideas from this code.. Hope it helps..
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)