Hi Telerik.
Im having problems by retrieving the values entered into a Textbox in the Grid which is wrapped in a GridTemplateColumn.
What i want to do: I want to have one textbox for each row in the grid. then when the user clicks a button i want to loop through the whole grid and save the DataKeyValue and the value enterd in the text box in a StringDictionary for later use...
my acx file look like below
My Code behind where i loop throught the items in the grid and svaed the data to a string dictionary looks like this
but im not able to retrieve the value from the textbox with this code. i only get a blank value.
I have the same problems if i try to use the build in edit functions in Radgrid. I cant switch to edit mode for the individual row enter my changes but im not able to catch the new values entered...
Im looking forward to you quick response.
Martin L
Im having problems by retrieving the values entered into a Textbox in the Grid which is wrapped in a GridTemplateColumn.
What i want to do: I want to have one textbox for each row in the grid. then when the user clicks a button i want to loop through the whole grid and save the DataKeyValue and the value enterd in the text box in a StringDictionary for later use...
my acx file look like below
| <telerik:RadGrid ID="RadGrid1" runat="server" PageSize="20" AllowSorting="True" Skin="Black" AllowPaging="True" |
| ShowGroupPanel="True" AutoGenerateColumns="False" GridLines="None"> |
| <PagerStyle Mode="NumericPages"></PagerStyle> |
| <MasterTableView Width="100%" TableLayout="Fixed" EditMode="InPlace" DataKeyNames="ProfitCenterNo" Name="Master"> |
| <GroupByExpressions> |
| <telerik:GridGroupByExpression> |
| <SelectFields> |
| <telerik:GridGroupByField FieldAlias="CostPlace" HeaderText=" " FieldName="CostPlace"></telerik:GridGroupByField> |
| </SelectFields> |
| <GroupByFields> |
| <telerik:GridGroupByField FieldName="CostPlace"></telerik:GridGroupByField> |
| </GroupByFields> |
| </telerik:GridGroupByExpression> |
| </GroupByExpressions> |
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="NewTargetCol" HeaderText="Enter Target" Visible="false"> |
| <ItemTemplate> |
| <asp:Panel ID="Panel1" runat="server"> |
| <asp:TextBox ID="NewTarget" runat="server" Text='<%# Bind("Target") %>'></asp:TextBox> |
| </asp:Panel> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn SortExpression="CostPlace" HeaderText="CostPlace" HeaderButtonType="TextButton" Visible="false" |
| DataField="CostPlace"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn SortExpression="ProfitCenterNo" HeaderText="" HeaderButtonType="TextButton" Visible="false" |
| DataField="ProfitCenterNo"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn ReadOnly="true" SortExpression="ProfitCenter" HeaderText="ProfitCenter" HeaderButtonType="TextButton" |
| DataField="ProfitCenter"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn ReadOnly="false" SortExpression="TurnOver" HeaderText="TurnOver" HeaderButtonType="TextButton" |
| DataField="TurnOver"> |
| <HeaderStyle/> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn SortExpression="Target" HeaderText="Target" HeaderButtonType="TextButton" UniqueName="Target" |
| DataField="Target"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn ReadOnly="true" SortExpression="GrwLastHour" HeaderText="Growth last hour" HeaderButtonType="TextButton" |
| DataField="GrwLastHour"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn ReadOnly="true" SortExpression="SpPrPax" HeaderText="Spending per pax" HeaderButtonType="TextButton" |
| DataField="SpPrPax"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn ReadOnly="true" SortExpression="TgPrPax" HeaderText="Target per pax" HeaderButtonType="TextButton" |
| DataField="TgPrPax"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn ReadOnly="true" SortExpression="RmPrPax" HeaderText="Remaining per pax" HeaderButtonType="TextButton" |
| DataField="RmPrPax"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| <asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" /> |
My Code behind where i loop throught the items in the grid and svaed the data to a string dictionary looks like this
| protected void Button2_Click(object sender, EventArgs e) |
| { |
| string profitCenterNo = ""; |
| string profitCenterTarget= ""; |
| StringDictionary sdProfitCenter = new StringDictionary(); |
| foreach (GridDataItem item1 in RadGrid1.Items) |
| { |
| if (item1.OwnerTableView.Name == "Master") |
| { |
| profitCenterNo = item1.GetDataKeyValue("ProfitCenterNo").ToString(); |
| profitCenterTarget = (item1["NewTargetCol"].FindControl("NewTarget") as TextBox).Text; |
| } |
| sdProfitCenter.Add(profitCenterNo, profitCenterTarget); |
| } |
| } |
but im not able to retrieve the value from the textbox with this code. i only get a blank value.
I have the same problems if i try to use the build in edit functions in Radgrid. I cant switch to edit mode for the individual row enter my changes but im not able to catch the new values entered...
Im looking forward to you quick response.
Martin L