Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi.

I have a gridview and inside the gridview there is a templated field , so i want to bind the lable of this templated field(item template) to the stored procedure in the sqlserver , and to change the lable text to what is selected from stored procedure .
here is the stored procedure :
SQL
ALTER PROCEDURE [dbo].[Get_LastIdHowzeEducationFinishDate_SP]
AS
BEGIN 
select he.FinishLevelDate as 'تاریخ اتمام سطح'
       from PersonHowEducation prh inner join HowzeEducation he on 
              prh.HowzeEducationId=he.HowzeEducationId
              where prh.IdCode=
              (Select IdCode from Persons where IdCode=IDENT_CURRENT('persons'))
END


and this is the code for calling stored procedure and to show it inside lable(item template):

C#
DataTable dt1 = DataProvider.ExecuteDataTable("[dbo].[Get_LastIdHowzeEducationFinishDate_SP]", CommandType.StoredProcedure);
GridView1.FindControl("Label1").DataBind();


but this exception appears:
Object reference not set to an instance of an object
how can i do that?
Posted

1 solution

Post the code of your ASPX page where you have defined the GridView.

For Binding, you will need to use the below statement -
C#
GridView1.DataSource = dt1;
GridView1.DataBind();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900