Last post Jul 28, 2016 10:45 AM by sjnaughton
Jul 27, 2016 04:12 PM|Mohsinkhan93|LINK
How do i make a checkbox “is update” clickable on grid view and when user check or uncheck the check box then field in database should update?
Jul 27, 2016 08:50 PM|march11|LINK
Well your jumping a little ahead with the Gridview, but you can handle this in the Click event of the check box,
You will need to read the Gridview row to get the info needed to update the database.
Make certain that the check box property Enable Postback is set to True.
This should get you started.
You will need to add a FindControl something like this to get the check box then test for its value....
Dim chkBox As CheckBox = DirectCast(row.FindControl("chkSelected"), CheckBox)
Do this inside a loop that iterates over each Griddview row.
For Each dr In GridView1.Rows
Jul 28, 2016 06:37 AM|Chris Zhao|LINK
You could use
<asp:CheckBox ID="chkRow" runat="server" OnCheckedChanged="chkRow_CheckedChanged" AutoPostBack="true"/>
protected void chkRow_CheckedChanged(object sender, EventArgs e)
CheckBox cb = (CheckBox)sender;
bool var1 = cb.Checked;
GridViewRow gvr = (GridViewRow)cb.Parent.Parent;
Jul 28, 2016 10:45 AM|sjnaughton|LINK
the In Dynamic Data you would get a checkbox automatically if the entity type for that column is of type Boolean. if you want to be able to check any row and update the underlying entity without going into edit mode for that row I believe with DD you will
have to add a custom Colum template like this:
<ItemStyle CssClass="center" />
<asp:CheckBox ID="Invoice" runat="server" />
this code goes in the <Columns> collection.
you will then need to handle the checkbox changed event.
The gridview is designed to work via data binding if you are wanting to have the data updated on checkbox change then you may be better looking at a client side framework like Angular or some such.