views:

301

answers:

2

I have a gridview that shows the content of a view in the database. The database view does group by on AppName in an underlying table and the view always shows count and average and (for the remaining columns) the latest added row in the underlying table.

In the gridview on webpage we only need to be able to update the latest added row in the database table. Plus we also need to be able to add new rows for one AppName at a time.

Thus we would like to have the following design of the Gridview in the webpage. (first row show in edit mode)

alt text

Update: should do a normal update to the shown row. We have an update stored procedure which does that in the underlying datatable

Add: should insert a new row in the underlying datatable. We have a insert stored procedure to insert the new values in the underlying datatable.

Note: 3 first columns in Gridview is read only.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:RoozzTestLogConnectionString %>" 
        DeleteCommand="TestLogDelete" DeleteCommandType="StoredProcedure" 
        InsertCommand="TestLogInsert" InsertCommandType="StoredProcedure" 
        SelectCommand="SELECT * FROM [EntryView]" UpdateCommand="TestLogUpdate" 
        UpdateCommandType="StoredProcedure">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="ID" Type="Int32" />
            <asp:Parameter Name="OSID" Type="Int32" />
            <asp:Parameter Name="BrowserID" Type="Int32" />
            <asp:Parameter Name="FWID" Type="Int32" />
            <asp:Parameter Name="AdminRights" Type="Boolean" />
            <asp:Parameter Name="TestUser" Type="String" />
            <asp:Parameter Name="Quality" Type="Int32" />
            <asp:Parameter Name="Message" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="AppID" Type="Int32" />
            <asp:Parameter Name="OSID" Type="Int32" />
            <asp:Parameter Name="BrowserID" Type="Int32" />
            <asp:Parameter Name="FWID" Type="Int32" />
            <asp:Parameter Name="AdminRights" Type="Boolean" />
            <asp:Parameter Name="TestUser" Type="String" />
            <asp:Parameter Name="Quality" Type="Int32" />
            <asp:Parameter Name="Message" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>

My problem is that Gridview does not work correctly in Edit mode.

  1. It does not bind correctly to dropdownlist values
  2. It does not run the update stored procedure and nor does it give an error message.
  3. Id does not run the insert stored procedure and nor does it give an error message.

Can anyone point to an example that will help me fix these problems?

A: 

i hope the following example will be helpful

Insert row in gridview

peacmaker
Sorry, but that was not exactly what I was looking for. However I found this very good tutorial, which is related to the same subject http://www.asp.net/learn/3.5-videos/video-500.aspx
Thomas3D
And here is another good tutorial. http://msdn.microsoft.com/en-us/library/ms972948.aspx(I have solved almost all problems now)
Thomas3D
A: 

I have solved my problems and posted two tutorial videos how I did here:

Video tutorial 1 of 2 Video tutorial 2 of 2

Thomas3D