设置DetailsView中的服务器控件ID 我想取出控件中的值
<asp:DetailsViewID="DetailsView1"runat="server"AutoGenerateRows="False"DataSourceID="...
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataSourceID="ObjectDataSource1" DefaultMode="Insert" Height="50px" OnItemInserting="DetailsView1_ItemInserting"
Width="489px">
<Fields>
<asp:BoundField DataField="SectionName" HeaderText="部门名称" SortExpression="SectionName">
<ControlStyle Width="300px" />
<ItemStyle Width="300px" />
<HeaderStyle Width="100px" />
<FooterStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="SectionId" HeaderText="部门编号" SortExpression="SectionId" />
<asp:BoundField DataField="SectionLeadership" HeaderText="负责人" SortExpression="SectionLeadership" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
string ss = ((TextBox)DetailsView1.FindControl("SectionLeadership")).Text;
}
提示"string ss = ((TextBox)DetailsView1.FindControl("SectionLeadership")).Text;"没有将引用到实例 展开
DataSourceID="ObjectDataSource1" DefaultMode="Insert" Height="50px" OnItemInserting="DetailsView1_ItemInserting"
Width="489px">
<Fields>
<asp:BoundField DataField="SectionName" HeaderText="部门名称" SortExpression="SectionName">
<ControlStyle Width="300px" />
<ItemStyle Width="300px" />
<HeaderStyle Width="100px" />
<FooterStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="SectionId" HeaderText="部门编号" SortExpression="SectionId" />
<asp:BoundField DataField="SectionLeadership" HeaderText="负责人" SortExpression="SectionLeadership" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
string ss = ((TextBox)DetailsView1.FindControl("SectionLeadership")).Text;
}
提示"string ss = ((TextBox)DetailsView1.FindControl("SectionLeadership")).Text;"没有将引用到实例 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询