inserting the one row in gridview

Posted by Swapnaidu under ASP.NET on 1/9/2013 | Points: 10 | Views : 1147 | Status : [Member] | Replies : 2
Hi my all friends

This is swapna. i topic is i have to insert the row within gridview by selecting item from dropdownlist(insideofgirdview), as well as using by textbox also in ASP + c# using . plz help waiting for u r valueble responce .


Thanks for all in advance




Responses

Posted by: Shubh on: 1/11/2013 [Member] Starter | Points: 25

Up
0
Down
Hii swapna!!

you can do insert code as well as you have to re-lode the page on the selection change event of your dropdownlist.
the code will be...like..

confunction();
con.Open();
string quest = "";
MySqlCommand cmd = new MySqlCommand("select que from query where queryname ='" + lbquery.SelectedItem.Text + "' ", con);
MySqlDataReader d = cmd.ExecuteReader();

while (d.Read())
{
quest = d["que"].ToString();
}
con.Close();
///////////////////////////////////////////////coded by shubh//////////////////////////////////////////////////
con.Open();
MySqlCommand cmd1 = new MySqlCommand(quest, con);
MySqlDataAdapter da = new MySqlDataAdapter(cmd1);
DataTable dt = new DataTable();
da.Fill(dt);
GridView2.DataSource = dt;
GridView2.DataBind(); Grid1.Visible = false;
GridView2.Visible = true;
con.Close();

but overall please specify your question that can help me to help you
thanks

Shubham Agrahari

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

Posted by: Shubham on: 1/12/2013 [Member] Starter | Points: 25

Up
0
Down
Hi!!! swapna
u could do this through itemtemplet in gridview
and u have do simply like u insert data from textbox or dropdownlist

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar

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

Login to post response