H
hazz
I am using the GridView to update a checkbox value (boolean to bit) for a
given row in a table. Works great.
I would like to be able to select 1 to n checkboxes without having to
individually click on the Edit hyperlink and clicking on the update for each
individual row. It's so tedious. How could I achieve a multiple row update?
My current code is below. Thank you. -Greg
<asp:sqldatasource id="CustomersSqlDataSource"
selectcommand="SELECT [ID], [Include_in_Report], [COLUMN_NAME] FROM
[ColumnsToSelectID]"
updatecommand="UPDATE ColumnsToSelectID SET Include_in_Report =
@Include_in_Report WHERE (ID = @ID)"
connectionstring="<%$ ConnectionStrings:dbConnectionString %>"
runat="server">
<UpdateParameters>
<asparameter Name="Include_in_Report" />
<asparameter Name="ID" />
</UpdateParameters>
</asp:sqldatasource>
void CustomersGridView_RowUpdated(Object sender, GridViewUpdatedEventArgs e)
{ if (e.Exception == null){
Message.Text = "Row updated successfully.";
}
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSqlDataSource"
allowpaging="True"
AutoGenerateColumns = "False"
onrowdatabound="CustomersGridView_RowDataBound"
datakeynames="ID"
onrowupdated="CustomersGridView_RowUpdated"
onrowcancelingedit="CustomersGridView_RowCancelingEdit"
onrowediting="CustomersGridView_RowEditing"
<columns>
<asp:CommandField ShowEditButton="True" />
<asp:boundfield datafield="ID" headertext="ID"/>
<asp:boundfield datafield="Column_Name" headertext="Column_Name"/>
<asp:checkboxfield datafield="Include_in_Report"
headertext="Include in Report"/>
</columns>
given row in a table. Works great.
I would like to be able to select 1 to n checkboxes without having to
individually click on the Edit hyperlink and clicking on the update for each
individual row. It's so tedious. How could I achieve a multiple row update?
My current code is below. Thank you. -Greg
<asp:sqldatasource id="CustomersSqlDataSource"
selectcommand="SELECT [ID], [Include_in_Report], [COLUMN_NAME] FROM
[ColumnsToSelectID]"
updatecommand="UPDATE ColumnsToSelectID SET Include_in_Report =
@Include_in_Report WHERE (ID = @ID)"
connectionstring="<%$ ConnectionStrings:dbConnectionString %>"
runat="server">
<UpdateParameters>
<asparameter Name="Include_in_Report" />
<asparameter Name="ID" />
</UpdateParameters>
</asp:sqldatasource>
void CustomersGridView_RowUpdated(Object sender, GridViewUpdatedEventArgs e)
{ if (e.Exception == null){
Message.Text = "Row updated successfully.";
}
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSqlDataSource"
allowpaging="True"
AutoGenerateColumns = "False"
onrowdatabound="CustomersGridView_RowDataBound"
datakeynames="ID"
onrowupdated="CustomersGridView_RowUpdated"
onrowcancelingedit="CustomersGridView_RowCancelingEdit"
onrowediting="CustomersGridView_RowEditing"
<columns>
<asp:CommandField ShowEditButton="True" />
<asp:boundfield datafield="ID" headertext="ID"/>
<asp:boundfield datafield="Column_Name" headertext="Column_Name"/>
<asp:checkboxfield datafield="Include_in_Report"
headertext="Include in Report"/>
</columns>