Santhonabin

Santhonabin

  • NA
  • 51
  • 212.7k

problem on Grid View update event using SQLDataSource

Feb 15 2011 6:42 AM

Hi..
Pls help to recover this problem ..
<
asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:TemplateField HeaderText="employname" SortExpression="employname">
<ItemTemplate>
<asp:Label ID="employname" runat="server"
text ='<%# Eval("employname") %>' >
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="employname" runat="server"
text ='<%# Eval("employname") %>' >
</asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="department" SortExpression="department">
<ItemTemplate>
<asp:Label ID="department" runat="server"
text ='<%# Eval("department") %>' >
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="department" runat="server"
text ='<%# Eval("department") %>' >
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="date" SortExpression="date">
<ItemTemplate>
<asp:Label ID="date" runat="server"
text ='<%# Eval("date") %>' >
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="date" runat="server"
text ='<%# Eval("date") %>' >
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [sample1]" DeleteCommand="DELETE [sample1] WHERE ([employname] = @employname)"
UpdateCommand="UPDATE [sample1] SET [department]=@department, [date]=@date WHERE [employname] = @employname">
<UpdateParameters>
<asp:FormParameter FormField="department" Type="string" Name="department" />
<asp:FormParameter FormField="date" Type="DateTime" Name="date" />
<asp:FormParameter FormField="employname" Type="string" Name="employname" />
</UpdateParameters>
<DeleteParameters >
<asp:Parameter Name="employname" Type="string" />
</DeleteParameters>
</asp:SqlDataSource>
Error: Must declare the scalar variable "@department".
 
if i take that @ in all parameters  then program is running but  fields are not updated...

Answers (3)