i placed datagrid in my from.....
and i have add buton ..
i have to type the values in the datagrid and insert it into my table
i am using windows application and code behind is c#.....
can any one help me?
For Answers, see/post comments
Datagrid Problem
Subscribe to:
Post Comments (Atom)
2 comments:
this coding is same in asp.net and VB.Net
SqlConnection con = new SqlConnection("server=. ; integrated security=sspi; database = Ram");
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from Ram ", con);
//SqlDataReader dr = com.ExecuteReader();
DataSet ds= new DataSet();
da.Fill(ds, "Ram");
GridView1.DataSource = ds;
GridView1.DataBind();
DropDownList2.DataSource = ds;
DropDownList2.DataTextField = "Name";
DropDownList2.DataBind();
ListBox1.DataSource = ds;
ListBox1.DataTextField = ds.Tables[0].Columns[1].ToString();
ListBox1.DataBind();
con.Close();
Hi,
To get all the values from your datagrid you can use this:
string sql = "";
foreach (DataGridViewRow dr in DgvTable.Rows)
{
if (Convert.ToString(dr.Cells[0].Value) != "")
{
sql = sql + Convert.ToString(dr.Cells[0].Value) + "," + Convert.ToString(dr.Cells[1].Value) ;
}
}
string[] sqlarr = sql.split(",");
Now you can get all of values in this array....
Post a Comment