0
我有這樣的GridView:GridViewCosts.SelectedRow.Cells [1]。文本不工作,ItemTemplate中
<div class ="gridView">
<asp:GridView ID="GridViewCosts" runat="server" ShowFooter="True" ShowHeaderWhenEmpty="True"
AutoGenerateColumns="False" OnRowDeleting="GridViewCosts_RowDeleting" Width="387px"
OnSelectedIndexChanged="GridViewCosts_SelectedIndexChanged"
OnPageIndexChanging="GridViewCosts_PageIndexChanging"
AllowPaging="True"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt" PageSize="5">
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<Columns>
<asp:BoundField DataField="Id" HeaderText="Номер" />
<asp:TemplateField HeaderText="Стойност">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Value") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Value") %>'></asp:Label>
</ItemTemplate>
<ControlStyle Width="100px" />
</asp:TemplateField>
而且在後面的代碼我想:
protected void GridViewCosts_SelectedIndexChanged(object sender, EventArgs e)
{
TextBoxValue.Text = GridViewCosts.SelectedRow.Cells[1].Text;
}
這是不工作時,列值是TemplateField。如果該列是BoundFIeld,那麼它正在工作。我該怎麼辦 ?