ASP.NET中的网格视图 [英] Grid View in ASP.NET
本文介绍了ASP.NET中的网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在练习使用存储过程在GridView中插入,更新,编辑。当我执行它时,我得到2个错误。错误是:
1.File''StoredProcedure.aspx.cs''未找到。
2.不能加载类型''_ StoreProcedure''
Pl有人引导我。
问候
Balamurugan
Hi,
I''m practising myself for Insert,Update,Edit in GridView using Stored Procedure.When i''m executing it i''m getting 2 errors. The errors are:
1.File ''StoredProcedure.aspx.cs'' was not found.
2.could not load type''_StoreProcedure''
Pl anyone guide me.
Regards
Balamurugan
推荐答案
Asp.net在gridview中插入,编辑,更新,删除数据 [ ^ ]
请参阅此片段并进行比较:
Please Refer to this Snippet and compare:
namespace Insert_update_delete_Stored_Pro
{
public partial class StoredProcedure : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
protected void BindGrid()
{
SqlConnection con = new SqlConnection(strConnString);
com = new SqlCommand();
con.Open();
com.Connection = con;
com.CommandText = "employee_pro";
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add(new SqlParameter("@status", SqlDbType.VarChar, 50));
com.Parameters["@status"].Value = "Display";
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
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=GRCPWS00051\MSSQLSERVER1;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();
}
}
u need to change ur data sourse accordingly an table name......
it works perfect
in aspxpage
in aspxpage
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
这篇关于ASP.NET中的网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文