Having a column with a checkbox where when the checkbox changes, it updates a table.
by Mufasa » Sat, 17 Nov 2007 04:20:24 GMT
I have a datagrid with a checkbox as a column that I read from a DB. I would
like to have it so that when a user clicks the checkbox it will
automatically save it to the DB so there doesn't have to be a submit/save
button. I realize I'm going to have to use autopostback and I plan on using
an Ajax UpdatePanel so it only updates the datagrid - not the whole page.
How can I implement this?
TIA - Jeff.
Similar Threads:
1.Problem sorting a Datagrid with Checkbox columns (checkboxes not following sort)
I am trying to sort a datagrid which contains 5 checkbox columns. All
other columns sort properly except these 5 checkbox columns which dont
sort at all.
I am using ASP.NET 1.1 and this code is located in a user control.
The code snippet for binding the checkbox control is as follows and is
found in the ItemDataBound event for the datagrid. It appears that
the index value never changes...it always seems to reference the
orginal dataset index.
Any help would be greatly appreciated.
try
{
System.Web.UI.WebControls.Image img1 =
(System.Web.UI.WebControls.Image)e.Item.Cells[7].Controls[1];
int iIndx = e.Item.DataSetIndex;
/*
0 Disabled
1 Approved
2 Waiting For Approval
3 Rejected
4 Locked
*/
int iResultSR = dsListBuilders.Tables["bb_saved_builders"].Rows[iIndx]
["sales_rep_approved"].ToString() == string.Empty?
2:int.Parse(dsListBuilders.Tables["bb_saved_builders"].Rows[iIndx]
["sales_rep_approved"].ToString());
switch(iResultSR)
{
case 0:
img1.ImageUrl="../../images/greybox.gif";
break;
case 1:
img1.ImageUrl="../../images/checkboxyes.gif";
break;
case 2:
img1.ImageUrl="../../images/checkboxno.gif";
break;
case 3:
img1.ImageUrl="../../images/redcheckboxno.gif";
break;
case 4:
img1.ImageUrl="../../images/lock.gif";
break;
default:
img1.ImageUrl="../../images/checkboxno.gif";
break;
}
}
catch(Exception exBinding1)
{
//ignore...
}
2.Problem sorting a Datagrid with Checkbox columns (checkboxes not f
Scott,
Instead of locating the data in the original table
dsListBuilders.Tables["bb_saved_builders"].Rows[iIndx]
use the grid source data:
DataRow row = (e.Item.ItemData is DataRow) ? e.Item.ItemData as DataRow :
(e.Item.ItemData as DataRowView).Row;
int iResultSR = (row["sales_rep_approved"].ToString() ==
string.Empty)?2:int.Parse(row["sales_rep_approved"].ToString());
"Scott" wrote:
> I am trying to sort a datagrid which contains 5 checkbox columns. All
> other columns sort properly except these 5 checkbox columns which dont
> sort at all.
>
> I am using ASP.NET 1.1 and this code is located in a user control.
>
> The code snippet for binding the checkbox control is as follows and is
> found in the ItemDataBound event for the datagrid. It appears that
> the index value never changes...it always seems to reference the
> orginal dataset index.
>
> Any help would be greatly appreciated.
>
> try
> {
> System.Web.UI.WebControls.Image img1 =
> (System.Web.UI.WebControls.Image)e.Item.Cells[7].Controls[1];
> int iIndx = e.Item.DataSetIndex;
> /*
> 0 Disabled
> 1 Approved
> 2 Waiting For Approval
> 3 Rejected
> 4 Locked
> */
> int iResultSR = dsListBuilders.Tables["bb_saved_builders"].Rows[iIndx]
> ["sales_rep_approved"].ToString() == string.Empty?
> 2:int.Parse(dsListBuilders.Tables["bb_saved_builders"].Rows[iIndx]
> ["sales_rep_approved"].ToString());
>
> switch(iResultSR)
> {
> case 0:
> img1.ImageUrl="../../images/greybox.gif";
> break;
> case 1:
> img1.ImageUrl="../../images/checkboxyes.gif";
> break;
> case 2:
> img1.ImageUrl="../../images/checkboxno.gif";
> break;
> case 3:
> img1.ImageUrl="../../images/redcheckboxno.gif";
> break;
> case 4:
> img1.ImageUrl="../../images/lock.gif";
> break;
> default:
> img1.ImageUrl="../../images/checkboxno.gif";
> break;
> }
> }
> catch(Exception exBinding1)
> {
> //ignore...
> }
>
>
3.A column of checkboxes (checkbox) in a list view (listview) control (.NET)
Hello!
In Visual Basic .NET (1.1)...
Is it possible to have a column of check boxes in a list view? So, for
example, a column named "Tested?" can have a boolean value assigned to
it in a nice, neat way?...
Product Name | Product version | Tested?
----------------------------------------------------
Prod1 | 1.1 | [ ]
Prod2 | 2.0 | [/]
Prod3 | 0.1 | [ ]
etc...
If not, what would be a good workaround (images?)
Thanks a lot!
Al.
4.Master-Detail Datagrid -checkbox (once tick the checkbox, all the child checkbox is ticked)
Does anyone know how to do this ??
Thanks a lot
5.CheckBox: Changing Only Checkbox not Text Backcolor
Hi
I am attempting to only set the Backcolor of a checkbox portion of the Checkbox control, not the text portion. Is it possible to separate the Backcolor text from the checkbox
Thanks
Mark
6. How to create a checkbox datatype column in a table in VB .net code
7. Update Checkbox Column in WebGrid
8. update checkbox values from gridview to database table.