是否可以使用我从文本框输入的值从Radgrid填充列?
这是我想从
获取值的文本框<asp:TextBox ID="txtaddNum" TextMode="Number" Width="30px" runat="server" min="1" MaxLength="100" step="1" AutoPostBack="true"></asp:TextBox>
这是我的radgrid,我希望添加值的列是&#34;承诺&#34;
<telerik:RadGrid ID="grdAddGoals" AllowPaging="True" AllowSorting="true" PageSize="8"
runat="server" AutoGenerateColumns="False" ShowStatusBar="true" EnableLinqExpressions="false"
GridLines="None" CellPadding="0" HeaderStyle-Height="30" CellSpacing="0" EnableEmbeddedBaseStylesheet="false"
EnableEmbeddedSkins="false" Skin="BasicBlue" AllowFilteringByColumn="false" OnPreRender="grdAddGoals_PreRender"
OnItemCreated="grdAddGoals_ItemCreated">
<MasterTableView EnableNoRecordsTemplate="true">
<NoRecordsTemplate>
<asp:Label ID="lblNoMessage" runat="server" ForeColor="Red" Text="No Goals Detail Found"></asp:Label>
</NoRecordsTemplate>
<Columns>
<telerik:GridTemplateColumn HeaderText="" AllowFiltering="false" HeaderStyle-Width="30px">
<ItemTemplate>
<span style="background: url('App_Themes/BasicBlue/images/arrow_table.png') no-repeat scroll center center transparent;
width: 30px; margin-top: 5px;"> </span>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Commitment" HeaderText="Commitment" AllowFiltering="false" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:TextBox ID="txtCommitment" runat="server" Width="109px"></asp:TextBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn UniqueName="GoalNumber" DataField="GoalNumber" HeaderText="Goal" ItemStyle-HorizontalAlign="Center"
AllowFiltering="false" HeaderStyle-Width="50px" ShowSortIcon="true" SortAscImageUrl="App_Themes/BasicBlue/images/sortorderasc_arrow.png"
SortDescImageUrl="App_Themes/BasicBlue/images/sortorderdesc_arrow.png">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings EnablePostBackOnRowClick="true">
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="true" FrozenColumnsCount="2" ScrollHeight="200px"
SaveScrollPosition="True" />
</ClientSettings>
</telerik:RadGrid>
我已经尝试了一切没有运气
答案 0 :(得分:0)
我的理解是,当您在&#34; txtaddNum&#34;中输入任何文字时您想要的文本框在(全部)&#39; txtCommitment&#39;中显示相同的文本textboxs。如果我不对,请告诉我。
请尝试使用以下代码段。
<强> ASPX.CS 强>
protected void txtaddNum_TextChanged(object sender, EventArgs e)
{
foreach (GridDataItem dataItem in grdAddGoals.MasterTableView.Items)
{
TextBox txtQuantity = (TextBox)dataItem.FindControl("txtCommitment");
txtQuantity.Text = txtaddNum.Text;
}
}
<强> ASPX 强>
<asp:TextBox ID="txtaddNum" TextMode="Number" Width="30px" runat="server" min="1" MaxLength="100" step="1"
AutoPostBack="true" OnTextChanged="txtaddNum_TextChanged"></asp:TextBox>
如果有任何疑虑,请告诉我。