2015-09-09 47 views
-2

我正在學習jquery.I想要一步步執行所有的事情。 我不得不給gridview將包含所有控件來更新,刪除記錄。什麼將是在.net而不是jqgrid中實現gridview的簡單方法。什麼是jqgrid的簡單替代?

+0

在互聯網上有很多jQuery網格視圖可用。你使用MVC或ASP.Net – tarzanbappa

+0

謝謝,ASP。淨 – user1838502

+0

如果你不需要jQuery,你可以使用ASP.Net gridview爲 – tarzanbappa

回答

0

既然你不需要使用ASP.net網格控制器或jq網格這裏有一些例子jQuery網格可用的網格插件。

http://www.aspdotnet-suresh.com/2014/08/7-jquery-grid-plugin-examples-or.html http://www.jquerybyexample.net/2012/04/jquery-grid-plugins-for-aspnet.html

如果您需要使用Asp.net GridView的控制器爲。這很簡單。

這是一個基本的樣本

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 



     <asp:GridView ID="GridView1" runat="server"> 

     </asp:GridView> 



    </div> 
    </form> 
</body> 
</html> 

你的C#代碼將是在GridView綁定

using System; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Linq; 
using System.Data.SqlClient; 


public partial class _Default : System.Web.UI.Page 
{ 

protected void Page_Load(object sender, EventArgs e) 
{ 
string strSQLconnection = (@"Data Source=.;Initial Catalog=new;Integrated Security=True"); 

SqlConnection sqlConnection = new SqlConnection(strSQLconnection); 

SqlCommand sqlCommand = new SqlCommand("select * from persons", sqlConnection); 

sqlConnection.Open(); 
SqlDataReader reader = sqlCommand.ExecuteReader(); 

GridView1.DataSource = reader; 

GridView1.DataBind(); 

} 

} 

正如你所說,你需要插入,修改,刪除,你可以參考網格視圖的列這些鏈接

http://www.aspneto.com/gridview-inline-add-insert-edit-update-delete-data-in-asp-net-c-vb.html

http://www.aspsnippets.com/Articles/Simple-Insert-Select-Edit-Update-and-Delete-in-ASPNet-GridView-control.aspx

+0

asp:GridView是一個asp控件。我不想要任何asp控件。 – user1838502

+0

我已經更新了答案,請參閱答案的頂部 – tarzanbappa