How to create dynamic gridview in asp.net c#?

Posted by Prabu_Spark under ASP.NET on 12/13/2012 | Points: 10 | Views : 18771 | Status : [Member] | Replies : 9
Hi sir,
Tell me the steps to create dynamic gridview in asp.net c#. Kindly give me the solution for this problem.

With regards,
J.Prabu.
[Email:prbspark@gmail.com]



Responses

Posted by: Sandhyab on: 12/13/2012 [Member] Starter | Points: 25

Up
0
Down
Once try this
 protected void Page_Load(object sender, EventArgs e)

{

GridView1.DataSource = GetResults();
GridView1.DataBind();

}
private DataTable GetResults()
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(string));
dt.Columns.Add("FirstName", typeof(string));
dt.Columns.Add("LastName", typeof(string));
dt.Columns.Add("Age", typeof(int));

dt.Rows.Add("1", "S", "B", "2");
return dt;
}


Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 12/14/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Add this on .Aspx Design page.
 

<asp:Panel ID="PanelGridView" runat="server">
</asp:Panel>

write this code on .CS page to Create dynamic gridview.

SqlDataAdapter da = new SqlDataAdapter(sqlQueryString, YourConnection);
DataSet ds = new DataSet();
da.Fill(ds);
GridView GridView1 = new GridView();
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
PanelGridView.Controls.Add(GridView1);


Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabusan on: 6/22/2013 [Member] Starter | Points: 25

Up
0
Down
hi mr.prabu...

this is prabu...

already i completed add dynamic gridview row with textbox controls with dropdownlist
like insert update delete operation. so what you exactly requirment...

........

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabusan on: 6/26/2013 [Member] Starter | Points: 25

Up
0
Down
hi prabu,,,i send the mail to you, pls u have to check ur mail, i attached sample add dynamic gridview row with textbox insert update delete operation

........

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar.Kodavali on: 8/16/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Prabu.
I had a task of creating dynamic grid having group of radio button control in some of the column in grid.
Please share me the code for creating dynamic grid and how to add controls in it.
Thanks.

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vignesh523 on: 9/21/2014 [Member] Starter | Points: 25

Up
0
Down
Hi prabhu, This is vignesh.. I need ur help pls ,I need source code for dynamic gridview with edit and save functionality.


Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vignesh523 on: 9/21/2014 [Member] Starter | Points: 25

Up
0
Down
Hi prabhu, this is my email id vignesh523@gmail.com

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vignesh523 on: 9/21/2014 [Member] Starter | Points: 25

Up
0
Down
hi prabhu... I am waiting ur reply

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenhcl on: 9/23/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

Use below sample.

protected void bind_GV()
{
DataTable dt=new DataTable();
dt.Columns.Add("col1");
dt.Columns.Add("col2");

DataRow dr=dt.NewRow();
dr[0]="1";
dr[1]="adasd";

dt.Rows.Add(dr);
GV.DataSource=dt;
GV.DataBind();
}


Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response