update one column globally rather than all columns by row.

Discussion in 'ASP .Net Datagrid Control' started by hazz, May 4, 2006.

  1. hazz

    hazz Guest

    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>
    hazz, May 4, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chuck Foster
    Replies:
    4
    Views:
    420
  2. David
    Replies:
    5
    Views:
    478
    David
    Nov 11, 2004
  3. Titus A Ducksass
    Replies:
    1
    Views:
    531
    David Dorward
    Aug 16, 2003
  4. Ralph Hartman
    Replies:
    1
    Views:
    201
    Raghavendra T V
    Aug 25, 2004
  5. Steven D'Aprano
    Replies:
    0
    Views:
    90
    Steven D'Aprano
    Dec 23, 2013
Loading...

Share This Page