Need Help with Gridview update
-
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
-
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
<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>