Selected下拉值正变为NULL,但是当我尝试填充文本时,我就能得到这些值。
HTML代码:
<div class="form-group">
<label>Indent No <font class="star_color"> * </font> </label>
<asp:TextBox ID="txtindentNo" runat="server" Class="form-control"
OnTextChanged="txtindentNo_TextChanged"></asp:TextBox>
</div>
<div class="form-group">
<label>Select Item <font class="star_color"> * </font> </label>
<asp:DropDownList ID="ddlItem" runat="server" class="form-control" AutoPostBack="true" OnSelectedIndexChanged="ddlItem_SelectedIndexChanged">
</asp:DropDownList>
</div>
<asp:TemplateField HeaderText="Indent Number " ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:Label ID="lblIndentNo" runat="server" Text='<%#Eval("IndentNumber") %>' Font-Size="Small"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Item" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblItem" runat="server" Text='<%#Eval("SeedItemNameEng") %>' Font-Size="Small"></asp:Label>
<asp:HiddenField ID="hdnItem" runat="server" Value='<%# Bind("SeedItemID") %>' />
</ItemTemplate>
</asp:TemplateField>
代码:
txtindentNo.Text = ((Label)grdItems.Rows[IndexValue].FindControl("lblIndentNo")).Text.Trim();
ddlItem.SelectedValue = ((Label)grdItems.Rows[IndexValue].FindControl("lblItem")).Text.Trim();