update one column globally rather than all columns by row.

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>
<asp:parameter Name="Include_in_Report" />
<asp:parameter 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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top