gridview update ques.

J

Jon Paal

when updating from a gridview, the value selected from a dropdownlist is applied to the field for all records in the table instead
of just the selected record. How can I fix this ?

....asp:SqlDataSource
UpdateCommand="UPDATE UserData SET status = @status WHERE userid = @userid ">
<UpdateParameters>
<asp:parameter Name="userid " Type="String" />
</UpdateParameters>

....asp:GridView
DataKeyNames="userid"

....
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Label id="label1" runat="server" Text='<%# Eval("Status") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" ID="ddlStatus"
AppendDataBoundItems="true"
SelectedValue='<%# Bind("status") %>'
DataSourceID= "SqlDataSource1"
AutoPostBack="False" >
<asp:ListItem Text="Open" Value="Open"></asp:ListItem>
<asp:ListItem Text="Closed" Value="Closed"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top