Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
i am preparing attendance management for my project and i am filling all details regarding faculty and subject and when i click OK button this values should saved to db and all details of student like name,number should be populate from db in gridview and 1 column with dropdownlist (present/absent) for faculty to fill for particular student should be generated and after filling all this values save to db.
Posted
Updated 18-Feb-14 7:49am
v4

You should be able to use conventional data binding in your text columns, like so:

XML
<asp:gridview id="gvPersons" runat="server" autogeneratecolumns="False" width="100px" xmlns:asp="#unknown">
    <columns>
        <asp:boundfield headertext="Name (long)" datafield="Name">
        <asp:templatefield headertext="ID">
          <itemtemplate>
            <asp:combobox id="comboPresent" runat="server">
            </asp:combobox>
          </itemtemplate>
        </asp:templatefield>
    </asp:boundfield></columns>
</asp:gridview>


Then use a TemplateField column for the ComboBox.

To populate the combo box column you can subscribe to the RowDataBound event of the GridView control, and then set the value manually there by casting the inner control of the second column to a ComboBox and setting it accordingly.
 
Share this answer
 
C#
protected void myCartGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    string prodCode = myCartGridView.DataKeys[e.RowIndex].Value.ToString();
    
    // change the values
    item.Size = ((DropDownList) myCartGridView.Rows[e.RowIndex].FindControl("sizeDropDown")).SelectedValue.ToString();
    item.Quantity = ((DropDownList) myCartGridView.Rows[e.RowIndex].FindControl("quantityDropDown")).SelectedValue.ToString();
    
    // Fire the UPDATE query here in order to update the changes in database..
    
    myCartGridView.EditIndex = -1;
    FillCartGrid();
}

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900