Click here to Skip to main content
15,886,049 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hello friends,
plz help me,
i show one gridview.in that i show answers of questions..if answer is three times 1 then i want one line after last 1...same as last 2..etc.but if run this code only 1st page line is display..after click on second page line is gone.i want solution.
Posted
Comments
Anandkumar D 18-Oct-12 6:57am    
Can you explain your question clearly?
AshishChaudha 18-Oct-12 6:57am    
Share your code please.

1 solution

If i understand you correctly, you want to add lines into GridView.
Just put the answers into a DataTable and bind it into GridView. Is this what you want?
For example,
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        System.Data.DataTable dt = new System.Data.DataTable();
        dt.Columns.Add("answers");

        GridView1 = new GridView();
        GridView1.AutoGenerateColumns = true;
        GridView1.DataSource = dt;
        GridView1.DataBind();

        ViewState["dt"] = dt;
    }
}

When you want to add answer
C#
void AddAnswer(string answer)
{
    System.Data.DataTable dt = (System.Data.DataTable)ViewState["dt"];
    dt.Rows.Add(answer);
    GridView1.DataSource = dt;
    GridView1.DataBind();
}
 
Share this answer
 
Comments
Vaishali P. Patil 18-Oct-12 8:44am    
hi,i bind answers to gridview but problem is i compair one by one attempt..so i got line but only first page..i goto next page line removed..i think this is page refresh problem..plz tell me..
adriancs 18-Oct-12 8:54am    
You can pass the value to next page in several ways. You can pass it by using SessionState.
Just change this:
ViewState["dt"]
to this:
SessionState["dt"]
the you can access the answers on the next page.

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