DetailsView做添加取值总是为空的
<div style=" z-index:3; top:45px; left:50px; position:relative;">
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True" AutoGenerateInsertButton="True" AutoGenerateRows="False"
Height="50px" OnItemInserting="DetailsView1_ItemInserting" OnModeChanging="DetailsView1_ModeChanging"
OnPageIndexChanging="DetailsView1_PageIndexChanging" Width="326px" OnItemDeleting="DetailsView1_ItemDeleting">
<Fields>
<asp:BoundField DataField="kch" HeaderText="课程号" />
<asp:BoundField DataField="kcm" HeaderText="课程名" />
<asp:BoundField DataField="kkxq" HeaderText="开课学期" />
<asp:BoundField DataField="xs" HeaderText="学时" />
<asp:BoundField DataField="xf" HeaderText="学分" />
</Fields>
</asp:DetailsView>
</div>
----------------------------------
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
string kch = (this.DetailsView1.Rows[0].Cells[1].Controls[0] as TextBox).Text;
}
------解决方案-------------------- 试试这样
C# code
TextBox dnTxtBox = (TextBox)gvWageBase.Rows[e.RowIndex].FindControl("TxtDepartName");
string DepartName = dnTxtBox.Text;
------解决方案--------------------