GridView1_RowDataBound事件中如何获得gridview当前行的ID
前台+<asp:TemplateFieldHeaderText="完成状态"><HeaderStyleHorizontalAlign="Left"></HeaderSty...
前台 +
<asp:TemplateField HeaderText="完成状态">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemStyle CssClass="String" Width="10%" />
<edititemtemplate>
<asp:DropDownList ID="PJStateDDList" runat="server" Width="90%">
</asp:DropDownList>
</edititemtemplate>
<itemtemplate>
<asp:Label id="RoleDisp" runat="server" text='<%# ChangeInttoString((int)Eval("PJState"))%>'></asp:Label>
</itemtemplate>
</asp:TemplateField>
后台
protected void TotalGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList PJStateList1 = (DropDownList)e.Row.FindControl("PJStateDDList");
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList PJStateList = new DropDownList();
PJStateList = e.Row.FindControl("PJStateDDList") as DropDownList;
if (PJStateList != null)
{
.......
}
}
总是提示 PJStateList‘NULl
可以给个简单的例子吗?谢谢 展开
<asp:TemplateField HeaderText="完成状态">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemStyle CssClass="String" Width="10%" />
<edititemtemplate>
<asp:DropDownList ID="PJStateDDList" runat="server" Width="90%">
</asp:DropDownList>
</edititemtemplate>
<itemtemplate>
<asp:Label id="RoleDisp" runat="server" text='<%# ChangeInttoString((int)Eval("PJState"))%>'></asp:Label>
</itemtemplate>
</asp:TemplateField>
后台
protected void TotalGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList PJStateList1 = (DropDownList)e.Row.FindControl("PJStateDDList");
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList PJStateList = new DropDownList();
PJStateList = e.Row.FindControl("PJStateDDList") as DropDownList;
if (PJStateList != null)
{
.......
}
}
总是提示 PJStateList‘NULl
可以给个简单的例子吗?谢谢 展开
展开全部
protected void TotalGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList PJStateList1 = ((DropDownList)e.Row.FindControl.("PJStateDDList"));
if (PJStateList1 != null)
{
.......
}
}
应该是这样子,你试试看后台代码,,前几天写了跟你差不多的。。只不过我是获取Button控件
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList PJStateList1 = ((DropDownList)e.Row.FindControl.("PJStateDDList"));
if (PJStateList1 != null)
{
.......
}
}
应该是这样子,你试试看后台代码,,前几天写了跟你差不多的。。只不过我是获取Button控件
追问
是不是GRIDVIEW属性设置有问题,否则按照你写的我修改了,PJStateList1还是null
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询