Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void LoadDesignCourseQuizez()
    {
         string semester = Semester.Text.ToString();
        string coursename = Course_Name.Text.ToString();
        DataTable dt = new DataTable();
        dt = IITBAL.FacultyCourses.GetDesignCourseQuizez(SessionId,coursename,semester);
        int quizez = Convert.ToInt32(dt.Rows[0]["Quizez"].ToString());
        for (int i = 1; i <= quizez; i++)
        {
            TemplateField tf = new TemplateField();
            tf.HeaderText = "Q" + i;
            GridView1.DataSource = tf;
            GridView1.DataBind();
          

        }

    }


I have Write this code to create Gridview with header text and textboxes Dynamically ...By problem can occur...any solution ????
Posted
Updated 24-Sep-14 21:34pm
v3
Comments
Harshad Kathiriya 25-Sep-14 3:44am    
Post the error here
Sinisa Hajnal 25-Sep-14 6:28am    
What problem? What error? Also your for loop should start at zero if you have to use all returned rows.
ZurdoDev 25-Sep-14 8:54am    
This is all wrong. You are setting the DataSource to a templateField. Why? What exactly are you trying to do?
[no name] 29-Sep-14 4:00am    
Could You plz explian your problem

1 solution

gvReportingStockComp.Columns[0].HeaderText = "New Header for First Column";


this is simple way to add grid view header from c#
 
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