Updating Gridview, Business Object, hide identity column

Last post 03-12-2007 5:40 PM by BasketballMike. 2 replies.

Sort Posts:

  • Updating Gridview, Business Object, hide identity column

    03-08-2007, 2:28 PM

    Hi,

    I created a BLL Class  "SubmitTime.cs" & BusObjDataSource control very similar to the TimeEntry class and ProjectListDataSource found on TimeEntry.aspx.  The select and update functions are very similar to the timeEntry select and update functions. 

    I wired up a gridview, my SubmitTime class and my select and update methods.  Everything works fine until I try hide the identity column (Which I use in my Update stored procedure in the DAL). 

    When I edit the column, and set  read only  = true or visible = false, the updates don't work.  My id column is not getting passed to the BusObjDataSource when it's hidden or read only.

    How can I hide this column and still pass the parameter?  Any help would be appreciated.

    Mike

  • Re: Updating Gridview, Business Object, hide identity column

    03-11-2007, 7:10 PM
    • Member
      596 point Member
    • vvsharma
    • Member since 02-12-2007, 8:14 PM
    • Posts 132

    Visible =false shouldnt matter.You should still be able to access it.

    Are you  using SqlDataSource for the Update method?if yes,make sure you have the Update parameters specified correctly.

    i.e 


    <asp:GridView ID="VanListGridView" runat="server"
    AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
    CellPadding="3" GridLines="Horizontal"
    DataSourceID="SqlDataSource1"  ... ................................
        <asp:SqlDataSource
    id="SqlDataSource1"
    runat="server"
    ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
    UpdateCommand="UPDATE Employees SET Address=@Address WHERE EmployeeID=@EmployeeID">
    <UpdateParameters>
    <asp:ControlParameter Name="Address" ControlId="TextBox1" PropertyName="Text"/>
    <asp:ControlParameter Name="EmployeeID" ControlId="DropDownList1" PropertyName="SelectedValue"/>
    </UpdateParameters>
    </asp:SqlDataSource>

    Info Source:http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.update(VS.80).aspx

     

    Vikram.S, Developer

    DiscountASP.NET

    Innovative ASP.NET Hosting & SQL Hosting
  • Re: Updating Gridview, Business Object, hide identity column

    03-12-2007, 5:40 PM
    Answer

    I changed the gridviews HTML code to this

    <

    asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="WeeklyTimeApprovalData" DataKeyNames="SummaryId">

    the DataKeyNames="SummaryId"> did the trick

     

    Mike

Page 1 of 1 (3 items)