Hi,
I am using DropDownList in Edit Mode of ListView. All other columns are updated, but dropdowns selected item is not updating, listview is passing old values to store procedure although i am forcefully passing new values of dropdown to store procedure. So how to pass new values to database.
This is my List View
Image of Item Template is here
http://www.freeimagehosting.net/bc3hm
This is ItemTemplate of List View
<ItemTemplate>
<tr >
<td>
<asp:Label ID="CountryCodeLabel" runat="server" Text='<%# Eval("CountryCode") %>'></asp:Label>
</td>
<td >
<asp:Label ID="CountryNameLabel" runat="server" Text='<%# Eval("CountryName") %>'></asp:Label>
</td>
<td>
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</td>
<td>
<asp:ImageButton runat=server ID=NameEdit ImageUrl="~/Image/edit.png" Width=20px CommandName="Edit" />   <asp:ImageButton runat=server ID="NameDelete" CommandName="Delete" ImageUrl="~/Image/delete.png" Width=20px />
</td>
</tr>
</ItemTemplate>
This is Edit Mode
Image For Edit is Here
http://www.freeimagehosting.net/8cxrt</a>
And my Edit Template is
<EditItemTemplate>
<tr>
<td>
<asp:TextBox ID="CodeTextBox" runat="server" Text='<%# Bind("CountryCode") %>' ></asp:TextBox>
</td>
<td >
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("CountryName") %>' ></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="NameDropDownList" runat="server" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="NameId" >
</asp:DropDownList>
</td>
<td>
<asp:ImageButton runat=server ID=UpdateSave ImageUrl="~/Image/save.png" Width=20px CommandName="Update" />   <asp:ImageButton runat=server ID="UpdateCancel" CommandName="Cancel" ImageUrl="~/Image/undo.png" Width=20px />
</td>
</tr>
</EditItemTemplate>
and For Updating i am handling this event
protected void ListView_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
DropDownList NameDropDownList = (DropDownList)((ListView)sender).Items[e.ItemIndex].FindControl("NameDropDownList ");
if (NameDropDownList!= null)
{
SqlDataSource1.UpdateParameters["NameId"].DefaultValue = NameDropDownList.SelectedValue;
}
}
So please help me how to solve that problem.
Thanks In Advance.