protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
con.Open();
string str = "select * from [order]";
SqlCommand cmd = new SqlCommand(str, con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
DropDownList d1 = (DropDownList)e.Row.FindControl("drop1");
d1.DataTextField = "product_id";
d1.DataSource = dt;
d1.DataBind();
}
}
Make button invisible and dropdownlist visible in gridview button click
protected void btnadd_Click(object sender, EventArgs e)
{
Button b1 = (Button)sender;
GridViewRow gr = (GridViewRow)b1.NamingContainer;
DropDownList drp = (DropDownList)GridView1.Rows[gr.RowIndex].FindControl("drp");
drp.Visible = true;
b1.Visible = false;
}
{
if (e.Row.RowType == DataControlRowType.Footer)
{
con.Open();
string str = "select * from [order]";
SqlCommand cmd = new SqlCommand(str, con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
DropDownList d1 = (DropDownList)e.Row.FindControl("drop1");
d1.DataTextField = "product_id";
d1.DataSource = dt;
d1.DataBind();
}
}
Make button invisible and dropdownlist visible in gridview button click
protected void btnadd_Click(object sender, EventArgs e)
{
Button b1 = (Button)sender;
GridViewRow gr = (GridViewRow)b1.NamingContainer;
DropDownList drp = (DropDownList)GridView1.Rows[gr.RowIndex].FindControl("drp");
drp.Visible = true;
b1.Visible = false;
}

