本文介绍了Rowdata绑定方法未被执行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void gvIssuedetails_RowDataBound(object sender,GridViewRowEventArgs e)

{

if(e.Row.RowType == DataControlRowType.DataRow)

{

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings [IssueTracker] .ConnectionString);

DropDownList ddlupdatestatus =(DropDownList)e.Row.FindControl(ddlupdatestatus );

标签lblupdatestatus =(标签)e.Row.FindControl(lblupdatestatus);

if(ddlupdatestatus!= null)

{

SqlCommand cmdselect = new SqlCommand();

SqlDataAdapter sda = new SqlDataAdapter(cmdselect);

cmdselect.CommandType = CommandType.StoredProcedure ;

cmdselect.CommandText =usp_getstatusclient;

cmdselect.Connectio n = con;

DataTable dt = new DataTable();

sda.Fill(dt);

if(dt.Rows.Count > 0)

{

ddlupdatestatus.DataSource = dt;

ddlupdatestatus.DataTextField =StatusName;

ddlupdatestatus .DataValueField =StatusId;

ddlupdatestatus.DataBind();

ddlupdatestatus.Items.Insert(0,new ListItem( - SELECT--,0 ));

}

else

{

ScriptManager.RegisterStartupScript(this,this.GetType() ,script,alert(''Source Not Available'');,true);

}

ddlupdatestatus.SelectedValue = lblupdatestatus.Text;

}

}

}





当我放置它不会转到这个方法的断点,它不会执行,tha t是为什么我无法在网格项目中绑定ddl。



请建议我解决一些问题。

解决方案

OnRowDataBound =gvIssuedetails_RowDataBound


protected void gvIssuedetails_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["IssueTracker"].ConnectionString);
DropDownList ddlupdatestatus = (DropDownList)e.Row.FindControl("ddlupdatestatus");
Label lblupdatestatus = (Label)e.Row.FindControl("lblupdatestatus");
if (ddlupdatestatus != null)
{
SqlCommand cmdselect = new SqlCommand();
SqlDataAdapter sda = new SqlDataAdapter(cmdselect);
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.CommandText = "usp_getstatusclient";
cmdselect.Connection = con;
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
ddlupdatestatus.DataSource = dt;
ddlupdatestatus.DataTextField = "StatusName";
ddlupdatestatus.DataValueField = "StatusId";
ddlupdatestatus.DataBind();
ddlupdatestatus.Items.Insert(0, new ListItem("--SELECT--", "0"));
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert(''Source Not Available'');", true);
}
ddlupdatestatus.SelectedValue = lblupdatestatus.Text;
}
}
}


when I place the breakpoint it doesnot goes to this method and it is not executed , that is why i am unable to bind the ddl in griditem.

Please suggest me some solution.

解决方案


这篇关于Rowdata绑定方法未被执行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 14:42