I m using GridView Controls to view the datas. For eg: I m getting column as username and displaying. Now i want to add Checkbox in gridview and want to store username and checkbox values in another table?

3 Years
Discussion Span
Last Post by h4ng4r18

Now that you have a Gridview with a Username Column - you can add a TemplateField containing the checkboxes (one per each row)

<asp:TemplateField HeaderText="ColumnHeaderHere" >
                                        <asp:CheckBox ID="ChBxSaveUsername" runat="server"/>

A button is needed outside of the Grivew for the purpose of saving.

<asp:Button ID="BtnSaveUsernames" runat="server" OnClick="BtnSaveUsernames_Click"/>

From the code behind - you can work through the GVRows with a for statement or a foreach statement and record which of the rows contain a checkbox with checked = true. I would add this usernames (or maybe userIds if available?) into an array/list or a comma-separated string and then pass them back into the database via a Stored Procedure.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.