Click here to Skip to main content
15,936,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a text box in my web form and a grid view. so what ever i write in the textbox that should be displayed in grid view when i click the submit button with out using the database.
plz help me..
Posted

1 solution

Hi ,
Check this
C#
List<string> dd = new List<string>();
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        if (ViewState["dd"] != null)
        {
            dd = (List<string>)ViewState["dd"];
        }
    }
}
protected void Button1_Click(object sender, EventArgs e)
{
    if (ViewState["dd"] != null)
    {
        dd = (List<string>)ViewState["dd"];
    }
    dd.Add(TextBox1.Text);
    GridView1.DataSource = dd.ToList();
    GridView1.DataBind();
    ViewState.Add("dd", dd);
}

Also you Can use datatable and fill it there is many ways you pick what you need
Hope it helps
Best Regards
M.Mitwalli
 
Share this answer
 
Comments
Member 8388026 17-Jun-12 5:46am    
Thanks a lot
Member 8388026 17-Jun-12 6:18am    
Its works
Mohamed Mitwalli 17-Jun-12 7:32am    
Your welcome :)

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