Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Need Help with Gridview update

Need Help with Gridview update

Scheduled Pinned Locked Moved ASP.NET
sysadminhelpquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jats_4ru
    wrote on last edited by
    #1

    I had created a Accessdatasource and a gridview to display data from a table and update it when neccessary. Please have a look at the below code.... Displaying and updating is working fine after lot of efforts... Now what i want to do is, update only three fields from the table, so i mentioned the first(ENo) field to readonly, in this case the updation is not taking place. If the readonly is removed the data is updated properly, but i dont want the user to change the value in first field(ENo). As it will update other rows with that no. How should i accomplish this... Please help... <asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/abc.mdb" SelectCommand="SELECT * FROM [Holiday] ORDER BY [ENo]" UpdateCommand="UPDATE [Holiday] SET [EName] = ?, [EDate] = ?, [EDay] = ? WHERE [ENo] = ?" DeleteCommand="DELETE FROM [Holiday] WHERE [ENo] = ?" InsertCommand="INSERT INTO [Holiday] ([ENo], [EName], [EDate], [EDay]) VALUES (?, ?, ?, ?)"> <DeleteParameters> <asp:Parameter Name="ENo" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="EName" Type="String" /> <asp:Parameter Name="EDate" Type="String" /> <asp:Parameter Name="EDay" Type="String" /> <asp:Parameter Name="ENo" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="ENo" Type="Int32" /> <asp:Parameter Name="EName" Type="String" /> <asp:Parameter Name="EDate" Type="String" /> <asp:Parameter Name="EDay" Type="String" /> </InsertParameters> </asp:AccessDataSource> <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="AccessDataSource2" Height="8px" Style="left: 0px; position: relative; top: 0px" Width="512px"> <Fo

    H 1 Reply Last reply
    0
    • J Jats_4ru

      I had created a Accessdatasource and a gridview to display data from a table and update it when neccessary. Please have a look at the below code.... Displaying and updating is working fine after lot of efforts... Now what i want to do is, update only three fields from the table, so i mentioned the first(ENo) field to readonly, in this case the updation is not taking place. If the readonly is removed the data is updated properly, but i dont want the user to change the value in first field(ENo). As it will update other rows with that no. How should i accomplish this... Please help... <asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/abc.mdb" SelectCommand="SELECT * FROM [Holiday] ORDER BY [ENo]" UpdateCommand="UPDATE [Holiday] SET [EName] = ?, [EDate] = ?, [EDay] = ? WHERE [ENo] = ?" DeleteCommand="DELETE FROM [Holiday] WHERE [ENo] = ?" InsertCommand="INSERT INTO [Holiday] ([ENo], [EName], [EDate], [EDay]) VALUES (?, ?, ?, ?)"> <DeleteParameters> <asp:Parameter Name="ENo" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="EName" Type="String" /> <asp:Parameter Name="EDate" Type="String" /> <asp:Parameter Name="EDay" Type="String" /> <asp:Parameter Name="ENo" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="ENo" Type="Int32" /> <asp:Parameter Name="EName" Type="String" /> <asp:Parameter Name="EDate" Type="String" /> <asp:Parameter Name="EDay" Type="String" /> </InsertParameters> </asp:AccessDataSource> <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="AccessDataSource2" Height="8px" Style="left: 0px; position: relative; top: 0px" Width="512px"> <Fo

      H Offline
      H Offline
      Herman T Instance
      wrote on last edited by
      #2

      <Columns> <asp:BoundField DataField="ENo" HeaderText="No." ReadOnly="true" /> <asp:BoundField DataField="EName" HeaderText="Event Name" /> <asp:BoundField DataField="EDate" HeaderText="Date" /> <asp:BoundField DataField="EDay" HeaderText="Day" /> <asp:CommandField ShowEditButton="True" /> </Columns>

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups