public DataSet GetHeadName() { _conn = new SqlConnection(str); _cmd = new SqlCommand("getheadname", _conn); _cmd.CommandType = CommandType.StoredProcedure; _cmd.CommandText = "getheadname"; SqlDataAdapter da = new SqlDataAdapter(_cmd); DataSet ds = new DataSet(); da.Fill(ds); return ds; } public DataSet GetArticalName() { _conn = new SqlConnection(str); _cmd = new SqlCommand("getarticlename", _conn); _cmd.CommandType = CommandType.StoredProcedure; _cmd.CommandText = "getarticlename"; SqlParameter p1 = null; p1 = new SqlParameter(); p1.ParameterName = "@articlename"; p1.Value = "TMAST_HEAD_NAME"; _cmd.Parameters.Add(p1); SqlDataAdapter da = new SqlDataAdapter(_cmd); DataSet ds = new DataSet(); da.Fill(ds); return ds; } if (e.Row.RowType == DataControlRowType.DataRow) { DropDownList ddlhead = (e.Row.FindControl("DropDownList1") as DropDownList); DropDownList ddlartical = (e.Row.FindControl("DropDownList2") as DropDownList); if (ddlhead != null && ddlartical != null) { ddlhead.DataSource = GetHeadName(); ddlhead.DataTextField = "TMAST_HEAD_NAME"; ddlhead.DataValueField = "TMAST_HEAD_NAME"; ddlhead.DataBind(); //Add Default Item in the DropDownList ddlhead.Items.Insert(0, new ListItem("--please select headname--")); ddlhead.SelectedValue = Gridview1.DataKeys[e.Row.RowIndex].Values[0].ToString(); ddlhead.DataSource = GetArticalName(); //ddlhead.DataTextField = "TMAST_ARTICLE_NAME"; //ddlhead.DataValueField = "TMAST_ARTICLE_NAME"; ddlhead.DataBind(); //Add Default Item in the DropDownList ddlhead.Items.Insert(0, new ListItem("--please select artical--")); // ddlhead.SelectedValue = Gridview1.DataKeys[e.Row.RowIndex].Values[2].ToString(); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Source Not Available');", true); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)