![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Jan 2005
Posts: 5
Rep Power: 0
![]() |
DropDownList in DataGrid not working!
Why doesn't this work....
I have... <asp:datagrid id=viewRequestDG runat="server" Width="100%" AutoGenerateColumns="False" DataMember="ShowRequest" DataSource="<%# viewRequestDS1 %>" OnEditCommand="EditClick" OnDeleteCommand="DeleteClick" OnUpdateCommand="SaveClick" OnCancelCommand="CancelClick"> ... <EditItemTemplate> <asp:DropDownList id=ddlStatus DataSource="<%# PopulateList() %>" Runat="server"> </asp:DropDownList> </EditItemTemplate> in my .aspx file then the functions... public void SaveClick(object sender, DataGridCommandEventArgs e)
{
DropDownList ddl = (DropDownList)e.Item.Cells[6].FindControl("ddlStatus");
DataRow row = viewRequestDS1.Tables["Request"].Rows[e.Item.ItemIndex];
row.ItemArray.SetValue(ddl.SelectedItem.Value.ToString(),7);
//row.ItemArray[7] = ddl.SelectedItem.Value.ToString();
RequestDA.Update(viewRequestDS1,"Request");
viewRequestDG.EditItemIndex = -1;
UpdateViewRequestDG();
}
public void EditClick(object sender, DataGridCommandEventArgs e)
{
viewRequestDG.EditItemIndex = e.Item.ItemIndex;
viewRequestDG.DataBind();
}
public string[] PopulateList()
{
string[] status = {"Hold", "Declined", "Accepted", "Paid"};
return status;
}in the .aspx.cs file... When I click the "Edit" Linkbutton, everything works fine. I see my dropdownlist with the right entries in the corresponding row. But when I select an entry from the dropdownlist and click save two problems happen... in the line with row.ItemArray.SetValue(ddl.SelectedItem.Value.ToString(),7); the ddl.SelectedItem.Value is always "Hold" or the 0 index, no matter what value I select in the DropDownList... Also in this line... The row.ItemArray.SetValue function doesn't work. It doesn't change the value of that cell in the DataSet... I have also tried... row.ItemArray[7] = ddl.SelectedItem.Value.ToString(); and this doesn't change row.ItemArray[7] either. Can anyone help? |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|