|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GridView: Update is just not working for methe update command button, the page refreshes but the new values do not make it to the database or back into the gridview. I'm getting the dreaded "Must declare the variable @original_RoleId" exception message. My source code looks like this: <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="RoleID" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound" OnRowUpdating="GridView1_RowUpdating"> <Columns> <asp:BoundField DataField="RoleName" HeaderText="RoleName" SortExpression="RoleName" /> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /> <asp:TemplateField HeaderText="Users In Role"> <ItemTemplate> <asp:Label ID="lblUserCount" runat="server" /> </ItemTemplate> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:CommandField ShowEditButton="True" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AAWSqlConnectionString %>" SelectCommand="SELECT RoleId, RoleName, LoweredRoleName, Description FROM aspnet_Roles" UpdateCommand="UPDATE aspnet_Roles SET [RoleName]=@RoleName, [Description]=@Description WHERE RoleId = @original_RoleID"> </asp:SqlDataSource> Any suggestions here? beaudetious Add within the ObjectDatasource definition the following attribute:
OldValuesParameterFormatString="original_{0}" This article woulde explain the usage of this attribute: http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasourceview.oldvaluesparameterformatstring.aspx Show quoteHide quote "beaudetious" wrote: > Can an eagle eye help me fix whatever is causing me pain here? When I click > the update command button, the page refreshes but the new values do not make > it to the database or back into the gridview. > > I'm getting the dreaded "Must declare the variable @original_RoleId" > exception message. My source code looks like this: > > <asp:GridView ID="GridView1" runat="server" AllowPaging="True" > AllowSorting="True" AutoGenerateColumns="False" > DataKeyNames="RoleID" DataSourceID="SqlDataSource1" > OnRowDataBound="GridView1_RowDataBound" > OnRowUpdating="GridView1_RowUpdating"> > > <Columns> > <asp:BoundField DataField="RoleName" HeaderText="RoleName" > SortExpression="RoleName" /> > <asp:BoundField DataField="Description" HeaderText="Description" > SortExpression="Description" /> > <asp:TemplateField HeaderText="Users In Role"> > <ItemTemplate> > <asp:Label ID="lblUserCount" runat="server" /> > </ItemTemplate> > <ItemStyle HorizontalAlign="Center" /> > </asp:TemplateField> > <asp:CommandField ShowEditButton="True" /> > </Columns> > </asp:GridView> > > <asp:SqlDataSource ID="SqlDataSource1" runat="server" > ConnectionString="<%$ ConnectionStrings:AAWSqlConnectionString %>" > SelectCommand="SELECT RoleId, RoleName, LoweredRoleName, Description FROM > aspnet_Roles" > UpdateCommand="UPDATE aspnet_Roles SET [RoleName]=@RoleName, > [Description]=@Description WHERE RoleId = @original_RoleID"> > </asp:SqlDataSource> > > Any suggestions here? > > beaudetious Excellent! That's what was missing. Thanks.
Show quoteHide quote "Phillip Williams" wrote: > Add within the ObjectDatasource definition the following attribute: > OldValuesParameterFormatString="original_{0}" > > This article woulde explain the usage of this attribute: > http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasourceview.oldvaluesparameterformatstring.aspx > > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "beaudetious" wrote: > > > Can an eagle eye help me fix whatever is causing me pain here? When I click > > the update command button, the page refreshes but the new values do not make > > it to the database or back into the gridview. > > > > I'm getting the dreaded "Must declare the variable @original_RoleId" > > exception message. My source code looks like this: > > > > <asp:GridView ID="GridView1" runat="server" AllowPaging="True" > > AllowSorting="True" AutoGenerateColumns="False" > > DataKeyNames="RoleID" DataSourceID="SqlDataSource1" > > OnRowDataBound="GridView1_RowDataBound" > > OnRowUpdating="GridView1_RowUpdating"> > > > > <Columns> > > <asp:BoundField DataField="RoleName" HeaderText="RoleName" > > SortExpression="RoleName" /> > > <asp:BoundField DataField="Description" HeaderText="Description" > > SortExpression="Description" /> > > <asp:TemplateField HeaderText="Users In Role"> > > <ItemTemplate> > > <asp:Label ID="lblUserCount" runat="server" /> > > </ItemTemplate> > > <ItemStyle HorizontalAlign="Center" /> > > </asp:TemplateField> > > <asp:CommandField ShowEditButton="True" /> > > </Columns> > > </asp:GridView> > > > > <asp:SqlDataSource ID="SqlDataSource1" runat="server" > > ConnectionString="<%$ ConnectionStrings:AAWSqlConnectionString %>" > > SelectCommand="SELECT RoleId, RoleName, LoweredRoleName, Description FROM > > aspnet_Roles" > > UpdateCommand="UPDATE aspnet_Roles SET [RoleName]=@RoleName, > > [Description]=@Description WHERE RoleId = @original_RoleID"> > > </asp:SqlDataSource> > > > > Any suggestions here? > > > > beaudetious
Event Sequence
ReportViewer/ObjectDataSource Problem objectdatasource.update() fires System.InvalidOperationException THEAD DropDownList not giving the selected item when a Button is clicked... please help newbie... Wizard Control and IsPostBack Styling DetailView or FormView Click event handler not called on dynamically create image button How to determine the "state" of a GridView Hide SideBar of Wizard Control |
|||||||||||||||||||||||