如何在asp.net中的按钮单击事件中调用RowDataBound事件?
如何在按钮点击事件中调用RowDataBound。我希望结果就像点击go按钮一样,它会自动在dropdownlist中显示输入的数据。但我不是这样得到的。我要做的事请帮帮我。我想你正在数据库中插入数据。插入后,获取数据并与gridview绑定 试试这个, GVPaperrate.DataBind; 为什么要评论这行。你应该取消评论这行,它会起作用的 你的按钮点击代码如何在asp.net中的按钮单击事件中调用RowDataBound事件?,asp.net,Asp.net,如何在按钮点击事件中调用RowDataBound。我希望结果就像点击go按钮一样,它会自动在dropdownlist中显示输入的数据。但我不是这样得到的。我要做的事请帮帮我。我想你正在数据库中插入数据。插入后,获取数据并与gridview绑定 试试这个, GVPaperrate.DataBind; 为什么要评论这行。你应该取消评论这行,它会起作用的 你的按钮点击代码 protected void GVPaperrate_RowDataBound(object sender, GridViewRo
protected void GVPaperrate_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataTable dtbirdtype = new DataTable();
objRetailPL.status = 5;
dtbirdtype = objRetailBAL.GetType(objRetailPL);
DropDownList ddl1 = (DropDownList)e.Row.FindControl("ddlType");
if (ddl1 != null)
{
ddl1.DataSource = dtbirdtype;
ddl1.DataTextField = "birdname";
ddl1.DataValueField = "sno";
ddl1.DataBind();
ddl1.Items.Add(new ListItem("--Select--", "0"));
ddl1.SelectedIndex = ddl1.Items.Count - 1;
}
DataTable dtzonedet = new DataTable();
dtzonedet = objRetailBAL.GetZoneDet();
DropDownList ddlzone = (DropDownList)e.Row.FindControl("ddlzone");
if (ddlzone != null)
{
ddlzone.DataSource = dtzonedet;
ddlzone.DataTextField = "ZoneName";
ddlzone.DataValueField = "SNo";
ddlzone.DataBind();
ddlzone.Items.Add(new ListItem("--Select--","0"));
ddlzone.SelectedIndex=ddlzone.Items.Count-1;
}
}protected void btngo_Click(object sender, ImageClickEventArgs e)
{
DataTable dtinsert = new DataTable();
objRetailPL.ZoneName = txtzone.Text.ToString();
objRetailPL.Username = Session["Username"].ToString();
dtinsert = objRetailBAL.InsertZone(objRetailPL);
if (dtinsert.Rows.Count > 0)
{
if (dtinsert.Rows[0]["status"].ToString() == "2")
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "insert", "alert('Saved Successfully')", true);
//GVPaperrate.DataBind();
txtzone.Text = "";
}
else if (dtinsert.Rows[0]["status"].ToString() == "1")
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "insert", "alert('ZoneName Already Exists')", true);
}
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "insert", "alert('Insertion Failed Please Consult IT Department')", true);
}
}
单击Go按钮后绑定网格或在页面上绑定网格\u PreRender方法。是否要使用gridview按钮单击事件?
protected void btngo_Click(object sender, ImageClickEventArgs e)
{
DataTable dtinsert = new DataTable();
objRetailPL.ZoneName = txtzone.Text.ToString();
objRetailPL.Username = Session["Username"].ToString();
dtinsert = objRetailBAL.InsertZone(objRetailPL);
if (dtinsert.Rows.Count > 0)
{
if (dtinsert.Rows[0]["status"].ToString() == "2")
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "insert", "alert('Saved Successfully')", true);
**GVPaperrate.DataBind()**; //why you comment this
txtzone.Text = "";
}
else if (dtinsert.Rows[0]["status"].ToString() == "1")
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "insert", "alert('ZoneName Already Exists')", true);
}
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "insert", "alert('Insertion Failed Please Consult IT Department')", true);
}
}