我正在尝试使用存储过程填充GridView
,但它不起作用,因为我没有看到错误。
以下是代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadGrid();
}
}
private void LoadGrid()
{
using (MathDBEntities1 db = new MathDBEntities1())
{
string name = Request.QueryString["qName"];
string ID = (from tbl in db.checkQuizName(name) select tbl.QuizID).FirstOrDefault();
GridView1.DataSource = db.QuestionsByQID(ID).ToList();
GridView1.DataBind();
}
}
存储过程代码
ALTER proc [dbo].[QuestionsByQID]
@quizID nvarchar
as begin
select * from dbo.Question where [QuizID] = @quizID
end
答案 0 :(得分:0)
根据OP的评论
ALTER proc [dbo].[QuestionsByQID]
@quizID nvarchar(max)
as begin
select * from dbo.Question where [QuizID] = @quizID
end