【发布时间】:2015-01-21 06:36:20
【问题描述】:
是否有可以从数据库中填充网格视图的 javascript?例如,此代码是否有 javascript? gvRFPCorpCode 是我的网格视图的名称
private void fillCorpCode()
{
DataSet ds = new DataSet();
data.gRowId = this.txtROWID.Text;
ds = data.GetCorpCode();
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
this.gvRFPCorpCode.DataSource = ds.Tables[0];
this.gvRFPCorpCode.DataBind();
}
}
}
ds = data.GetCorpCode();等于这个:
public DataSet GetCorpCode()
{
DataSet ds = new DataSet();
SqlParameter[] sqlParam = new SqlParameter[]
{
new SqlParameter("@RowId",sRowId)
};
if (this.InitDataLayerObject() == true)
{
ds = this.ExecuteQuery("dbo.sp_ESS_RFP_GetCorpCode", sqlParam);
}
return ds;
}
这是一个存储过程,这里是我的存储过程“dbo.sp_ESS_RFP_GetCorpCode”
ALTER PROCEDURE [dbo].[sp_ESS_RFP_GetCorpCode]
-- Add the parameters for the stored procedure here
@RowId varchar(max)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @xml as xml
select
@xml =convert(xml,CORPCODE)
from Tbl_ESS_Request_For_Payment_Save
where ROWID=@RowId
select
tbl.col.value('CorpCode[1]', 'varchar(100)') as CorpCode,
tbl.col.value('Amount[1]', 'varchar(100)')as Amount
from @xml.nodes('/NewDataSet/Table1') tbl(col)
END
我想要的是有一个等效于 private void fillCorpCode 的 javascript 来在我的 gridview 上填充它,顺便说一句,如果我已经在 c# 中有代码,你可能会问为什么我需要一个 javascript,这是因为我的程序中有一些过程而且很难解释。所以请帮我解决这个问题,提前谢谢!
【问题讨论】:
-
如果您需要的话,有许多 JavaScript 框架/插件可以以最少的配置创建数据网格视图。搜索“datatable javascript”或“grid view javascript”,您会找到其中的一些。
-
您需要在您的 javascript 函数中调用 getJSON。将 DS 序列化为 JSON 对象并构造一个 HTML 表以像 Gridview 一样显示。当您说网格视图时,它具有诸如事件处理程序、属性等相关的好处。如果您在 js 中这样做,这将不会是 avbl
-
@Saravanan 你能用代码回答我的问题吗?我不知道 getJSON。
标签: javascript c# asp.net stored-procedures gridview