aspx代码如下: <EmptyDataTemplate> <asp:DetailsView runat="server" DataSource DefaultMode="Insert" Height="50px" Width="125px" oniteminserted="DetailsView1_ItemInserted" AutoGenerateRows="False" DataKeyNames="id"> <FieldHeaderStyle Wrap="False" /> <Fields> <asp:BoundField DataField="chuliren" HeaderText="处理人" SortExpression="chuliren" /> <asp:BoundField DataField="shenqingren" HeaderText="申请人" SortExpression="shenqingren" /> <asp:BoundField DataField="gongsi" HeaderText="公司" SortExpression="gongsi" /> <asp:TemplateField HeaderText="部门" SortExpression="bumen"> <EditItemTemplate> <asp:DropDownList runat="server" DataSource DataTextField="bumen" DataValueField="bumen" AutoPostBack="True" > </asp:DropDownList> <asp:SqlDataSource runat="server" ConnectionString="<%$ ConnectionStrings:dngzConnectionString %>" SelectCommand="SELECT * FROM [jiagou]"></asp:SqlDataSource> </EditItemTemplate> </asp:TemplateField> </Fields> <HeaderStyle Wrap="True" /> </asp:DetailsView> </EmptyDataTemplate>aspx.cs代码如下:protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { string str = ((DropDownList)DetailsView1.Rows[3].Cells[1].FindControl("DropDownList1")).SelectedItem.Text;e.Values.Add("type", str); } 运行的时候,显示string str = ((DropDownList)DetailsView1.Rows[3].Cells[1].FindControl("DropDownList1")).SelectedItem.Text;有错误,DetalisView1不存在上下文中,这是为什么呢?这个是在gridview之内的,还有是在UpdatePanel之内,还有是在ContentPlaceHolder之内,不知道是不是受这些影响?如何修改?
- 1 回答
- 0 关注
- 232 浏览
添加回答
举报
0/150
提交
取消