There is a gridview in my webform. If I add records in it then it does not display on the front end but gets saved in the database. I think I have to add insert join to two tables because while displaying the gridview I have used select join, that's why it's not showing in front end.
The first query is in my code and second query is
insert into SubmenuRec(Menu_ID, SubMenu_id) Values(@MenuID,@SubMenu_id)
Can I use join here for displaying new added records in table, and if yes then how?
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
TextBox txtSubMenu_id = (TextBox)GridView1.FooterRow.FindControl("txtftrSubMenu_id");
TextBox txtSubmenu_name = (TextBox)GridView1.FooterRow.FindControl("txtfSubmenu_name");
String strConnString = ConfigurationManager.ConnectionStrings["CallcenterConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
con.Open();
SqlCommand cmd =
new SqlCommand(
"insert into Submenu(SubMenu_id,Submenu_name) values('" + txtSubMenu_id.Text + "','" + txtSubmenu_name.Text + "')", con);
int result = cmd.ExecuteNonQuery();
con.Close();
if (result == 1)
{
lblresult.Text = " Details inserted successfully";
}
else
{
lblresult.Text = " Details not inserted";
}
}
}