Step- 1
List<CAT_MST> List = new List<CAT_MST>();
Step- 2
protected void btnAdd_Click(object sender, EventArgs e)
{
string drpval =drpCategory.SelectedItem.ToString();
CAT_MST obj = new CAT_MST();
obj.cat_name3 = drpval;
if(ViewState["SaveList"]!=null)
{
List = ((List < CAT_MST>)ViewState["SaveList"]).ToList();
}
List.Add(obj);
ViewState["SaveList"] = List;
GridView1.DataSource = ViewState["SaveList"];
GridView1.DataBind();
}
List<CAT_MST> List = new List<CAT_MST>();
Step- 2
protected void btnAdd_Click(object sender, EventArgs e)
{
string drpval =drpCategory.SelectedItem.ToString();
CAT_MST obj = new CAT_MST();
obj.cat_name3 = drpval;
if(ViewState["SaveList"]!=null)
{
List = ((List < CAT_MST>)ViewState["SaveList"]).ToList();
}
List.Add(obj);
ViewState["SaveList"] = List;
GridView1.DataSource = ViewState["SaveList"];
GridView1.DataBind();
}