Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hy I want to bind daa in gridview using C# and I want auto edit also Please help me

.aspx File

XML
<form id="form1" runat="server">
 <div>
     <asp:GridView ID="GridView1" Width="50%" runat="server" CellPadding="2" ForeColor="#333333" GridLines="None">
         <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
         <EditRowStyle BackColor="#999999" />
         <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
         <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
         <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
         <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
         <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
         <SortedAscendingCellStyle BackColor="#E9E7E2" />
         <SortedAscendingHeaderStyle BackColor="#506C8C" />
         <SortedDescendingCellStyle BackColor="#FFFDF8" />
         <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
           <Columns>
             <asp:CommandField ShowEditButton="True" />
         </Columns>
     </asp:GridView>
          <asp:SqlDataSource ID="" runat="server" ConnectionString="<%$ ConnectionStrings:CMMS_Standard %>" ProviderName="<%$ ConnectionStrings:CMMS_Standard.ProviderName %>" SelectCommand="SELECT * FROM [Currency_Table]" DeleteCommand="DELETE FROM [Currency_Table] WHERE [Currency_Id] = @Currency_Id" InsertCommand="INSERT INTO [Currency_Table] ([Currency_Id], [Currency_Name], [Currency_Code], [Country_Name]) VALUES (@Currency_Id, @Currency_Name, @Currency_Code, @Country_Name)" UpdateCommand="UPDATE [Currency_Table] SET [Currency_Name] = @Currency_Name, [Currency_Code] = @Currency_Code, [Country_Name] = @Country_Name WHERE [Currency_Id] = @Currency_Id">
         <DeleteParameters>
             <asp:Parameter Name="Currency_Id" Type="Byte" />
         </DeleteParameters>
         <InsertParameters>
             <asp:Parameter Name="Currency_Id" Type="Byte" />
             <asp:Parameter Name="Currency_Name" Type="String" />
             <asp:Parameter Name="Currency_Code" Type="String" />
             <asp:Parameter Name="Country_Name" Type="String" />
         </InsertParameters>
         <UpdateParameters>
             <asp:Parameter Name="Currency_Name" Type="String" />
             <asp:Parameter Name="Currency_Code" Type="String" />
             <asp:Parameter Name="Country_Name" Type="String" />
             <asp:Parameter Name="Currency_Id" Type="Byte" />
         </UpdateParameters>
     </asp:SqlDataSource>

 </div>
 </form>



.aspx.cs
C#
string Connection_string = System.Configuration.ConfigurationManager.ConnectionStrings["CMMS_Standard"].ToString();

   protected void Page_Load(object sender, EventArgs e)
   {
       DataTable dt = null;
       Test t = new Test();
       t.Retrieve_Currency_By_All(ref Connection_string, out dt);
       GridView1.DataSource =dt ;
       GridView1.DataBind();
   }



Now I want autorow edit Option
Posted
Updated 3-Apr-15 1:01am
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900