bopritchard
Programmer
i've got a datagrid that has a dropdownlist(populated in the datasource property) control in it...
i'm creating the dataset for the datagrid using the code below...
so when a selection is made in the dropdownlist and the update button is hit...the "id" and "name" values should be saved to the dataset and then a editable row inserted below it in the datagrid so that another dropdownlist selection can be made...
[highlight #FF99FF]QUESTION[/highlight]
On postback how do I save the data from the dropdown list to the dataset and insert blank row below the saved one...make sense?
DataSet Creation Code
Datagrid Code
i'm creating the dataset for the datagrid using the code below...
so when a selection is made in the dropdownlist and the update button is hit...the "id" and "name" values should be saved to the dataset and then a editable row inserted below it in the datagrid so that another dropdownlist selection can be made...
[highlight #FF99FF]QUESTION[/highlight]
On postback how do I save the data from the dropdown list to the dataset and insert blank row below the saved one...make sense?
DataSet Creation Code
Code:
DataSet dsExaminers = new DataSet();
DataTable dtExaminers = new DataTable();
DataColumn dcExaminers = new DataColumn("id");
dtExaminers.Columns.Add(dcExaminers);
dcExaminers = new DataColumn("name");
dtExaminers.Columns.Add(dcExaminers);
DataRow drExaminers = dtExaminers.NewRow();
dtExaminers.Rows.Add(drExaminers);
dsExaminers.Tables.Add(dtExaminers);
Examiners.EditItemIndex = dsExaminers.Tables[0].Rows.Count - 1;
Examiners.DataSource = dsExaminers;
Examiners.DataBind();
Datagrid Code
Code:
<asp:datagrid id="Examiners" Width="95%" Runat="server" OnCancelCommand="ExaminersDataCancel"
OnUpdateCommand="ExaminersDataUpdate" OnEditCommand="ExaminersDataEdit" OnDeleteCommand="ExaminersDataDelete"
DataKeyField="ID" AutoGenerateColumns="False" Height="10px" OnItemDataBound="ExaminersDataBind">
<Columns>
<asp:TemplateColumn HeaderText="Examiners">
<ItemTemplate>
'<%# DataBinder.Eval(Container.DataItem, "Name") %>'
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList id=ExaminerList runat=server Width=80% DataValueField="ID" DataTextField="Name" DataSource='<%# CCSExamination.GetExaminers() %>' />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button ID="Edit" Text="Edit" CssClass="Button" CommandName="Edit" Runat="server" Width="50" />
<asp:Button ID="Delete" Text="Delete" CssClass="Button" CommandName="Delete" Runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="Update" Text="Update" CssClass="button" CommandName="Update" Runat="server" />
<asp:button ID="editCancel" Text="Cancel" CssClass="button" CommandName="Cancel" Runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>