I am working porting ugly .NET 1.1 DataGrids to 2.0 GridViews. The GridView fills correctly via SqlDataSource. When I click Edit -> [make a field change] -> Update, the page refreshes but the update command clearly never fired. (Putting stuff in the GridView's OnRowUpdating function proves this.) The row also remains in edit mode.
The code:
[code=html]<asp:SqlDataSou rce ID="dsMyReports " runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:vortex2devCo nnectionString %>"
SelectCommand=" SELECT [ID], [Name], [Description] FROM [Report] WHERE (([IsPublic] = @IsPublic) AND ([OwnedByUserID] = @userID))"
OnSelecting="ds MyReports_Selec ting"
DeleteCommand=" DELETE FROM Report WHERE ID = @reportID"
UpdateCommand=" UPDATE Report SET Name = @Name, Description = @Description WHERE ID = @ID">
<SelectParamete rs>
<asp:Paramete r DefaultValue="0 " Name="IsPublic" Type="Int32" />
<asp:Paramete r DefaultValue="" Name="userID" Type="Int32" />
</SelectParameter s>
<DeleteParamete rs>
<asp:Paramete r Name="reportID" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="Name" />
<asp:Paramete r Name="Descripti on" />
<asp:Paramete r Name="ID" />
</UpdateParameter s>
</asp:SqlDataSour ce>
<asp:GridView ID="myReportsGr id" runat="server" AutoGenerateCol umns="False" DataSourceID="d sMyReports" DataKeyNames="I D">
<Columns>
<asp:BoundFie ld DataField="Name " HeaderText="Nam e" SortExpression= "Name" />
<asp:BoundFie ld DataField="Desc ription" HeaderText="Des cription" SortExpression= "Descriptio n" />
<asp:CommandFie ld ControlStyle-Width="16px" ButtonType="Ima ge" EditImageUrl="~/images/edit_icon2.gif" ShowEditButton= "true" />
</Columns>
</asp:GridView>[/code]
Thanks!
The code:
[code=html]<asp:SqlDataSou rce ID="dsMyReports " runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:vortex2devCo nnectionString %>"
SelectCommand=" SELECT [ID], [Name], [Description] FROM [Report] WHERE (([IsPublic] = @IsPublic) AND ([OwnedByUserID] = @userID))"
OnSelecting="ds MyReports_Selec ting"
DeleteCommand=" DELETE FROM Report WHERE ID = @reportID"
UpdateCommand=" UPDATE Report SET Name = @Name, Description = @Description WHERE ID = @ID">
<SelectParamete rs>
<asp:Paramete r DefaultValue="0 " Name="IsPublic" Type="Int32" />
<asp:Paramete r DefaultValue="" Name="userID" Type="Int32" />
</SelectParameter s>
<DeleteParamete rs>
<asp:Paramete r Name="reportID" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="Name" />
<asp:Paramete r Name="Descripti on" />
<asp:Paramete r Name="ID" />
</UpdateParameter s>
</asp:SqlDataSour ce>
<asp:GridView ID="myReportsGr id" runat="server" AutoGenerateCol umns="False" DataSourceID="d sMyReports" DataKeyNames="I D">
<Columns>
<asp:BoundFie ld DataField="Name " HeaderText="Nam e" SortExpression= "Name" />
<asp:BoundFie ld DataField="Desc ription" HeaderText="Des cription" SortExpression= "Descriptio n" />
<asp:CommandFie ld ControlStyle-Width="16px" ButtonType="Ima ge" EditImageUrl="~/images/edit_icon2.gif" ShowEditButton= "true" />
</Columns>
</asp:GridView>[/code]
Thanks!
Comment