在gridview中检索数据 [英] retrieve data in gridview

查看:61
本文介绍了在gridview中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hy我想使用C#在gridview中绑定daa并且我想要自动编辑也请帮助我



.aspx文件



Hy I want to bind daa in gridview using C# and I want auto edit also Please help me

.aspx File

<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




.aspx.cs

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

推荐答案

ConnectionStrings:CMMS_Standard %> ProviderName = < ;%
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:参数 名称 = Currency_Id 类型 = 字节 / >
< / DeleteParameters >
< InsertParameters >
< asp:参数 名称 = Currency_Id 类型 = 字节 / >
< asp:参数 名称 = Currency_Name 类型 = 字符串 / >
< asp:参数 名称 = Currency_Code T ype = 字符串 / >
< asp:参数 名称 = Country_Name 类型 = 字符串 / >
< / InsertParameters >
< UpdateParameters >
< asp:参数 < span class =code-attribute> 名称 = Currency_Name 类型 = 字符串 / >
< asp:参数 名称 = Currency_Code 类型 = 字符串 / >
< asp:参数 名称 = Country_Name 类型 = 字符串 < span class =code-attribute> / >
< asp:参数 名称 = Currency_Id 类型 = 字节 / >
< / UpdateParameters >
< / asp:SqlDataSource >

< / div >
< / form >
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>



< br $> b $ b

.aspx.cs




.aspx.cs

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


您好,

查看以下链接

http://csharp.net-informations.com/datagridview/csharp-datagridview-sql-server.htm [ ^ ]


这篇关于在gridview中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆