This is a migrated thread and some comments may be shown as answers.

[Solved] Accessing content of template fields

3 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clifford Lane
Top achievements
Rank 1
Clifford Lane asked on 23 Feb 2010, 12:03 PM
I have a form with three grids each has a edititemtemplate with several fields and an update/insert button and a cancel button.

I need to access the content of each field prior to update/insert to make sure the content is valid.

One of the grids is named FULEGRID.  On the click event for the update/insert needs to access the tbx fields inthe template but I can't seem construct the statement needed to 'view' their content.  Give the following code can someone help out?

Cliff

Here is the source for this grid

 

<telerik:RadGrid ID="fuelgrid" runat="server" DataSourceID="SqlDataSource1"  GridLines="None"     AllowAutomaticInserts="True"     AllowAutomaticUpdates="True" AutoGenerateEditColumn="True" Skin="Hay">

 

 

<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="Id"

 

 

DataSourceID="SqlDataSource1">

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</RowIndicatorColumn>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

<telerik:GridEditCommandColumn>

 

 

</telerik:GridEditCommandColumn>

 

 

<telerik:GridBoundColumn DataField="Id" DataType="System.Int64" HeaderText="Id" ReadOnly="True"

 

 

SortExpression="Id" UniqueName="Id" Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="fleet_id" DataType="System.Int64" HeaderText="fleet_id" SortExpression="fleet_id" UniqueName="fleet_id" Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="beginning_miles" DataType="System.Double" HeaderText="Starting Miles"

 

 

SortExpression="beginning_miles" UniqueName="beginning_miles">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="ending_miles" DataType="System.Double" HeaderText="Ending Miles"

 

 

SortExpression="ending_miles" UniqueName="ending_miles">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="gas_date" DataFormatString="{0:MM/dd/yyyy}" DataType="System.DateTime"

 

 

HeaderText="Fill-up Date" SortExpression="gas_date" UniqueName="gas_date">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="gas_gallons" DataType="System.Double" HeaderText="Gallons"

 

 

SortExpression="gas_gallons" UniqueName="gas_gallons">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="gas_amt" DataType="System.Decimal" HeaderText="Price"

 

 

SortExpression="gas_amt" UniqueName="gas_amt" DataFormatString="{0:C}">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="create_date" DataType="System.DateTime" HeaderText="create_date"

 

 

SortExpression="create_date" UniqueName="create_date" Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="create_id" HeaderText="create_id" SortExpression="create_id"

 

 

UniqueName="create_id" Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

<EditFormSettings EditFormType="Template">

 

 

<EditColumn UniqueName="EditCommandColumn1">

 

 

</EditColumn>

 

 

<FormTemplate>

 

 

<table style="width: 245px; height: 117px">

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblstart" runat="server" Text="Starting Miles"></asp:Label></td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxstartingmiles" runat="server" Text='<%# Bind("beginning_miles") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label1" runat="server" Text="######"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblend" runat="server" Text="Ending Miles"></asp:Label></td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxendingmiles" runat="server" Text='<%# Bind("ending_miles") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label2" runat="server" Text="######"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblgallons" runat="server" Text="Gallons"></asp:Label></td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxgallons" runat="server" Text='<%# Bind("gas_gallons") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label3" runat="server" Text="###.#"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblgamt" runat="server" Text="Price"></asp:Label></td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxgamt" runat="server" Text='<%# Bind("gas_amt") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label4" runat="server" Text="$$$$.$$"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblgdate" runat="server" Text="Fill-up Date"></asp:Label>

 

 

</td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxgdate" runat="server" Text='<%# Bind("gas_date") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label5" runat="server" Text="mm/dd/yyyy"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td colspan="3">

 

 

<asp:Button ID="btnupdate" runat="server"

 

 

Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'

 

 

CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' OnClick="btnupdate_Click"/>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td colspan="3">

 

 

<asp:Button ID="btncancel" runat="server" Text="Cancel" CausesValidation="false"

 

 

CommandName="Cancel" />

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td colspan="3">

 

 

<asp:TextBox ID="tbxfleetid" runat="server"

 

 

Text='<%# Bind("fleet_id") %>'

 

 

Visible="False"></asp:TextBox>

 

 

<asp:TextBox ID="tbxcreaterid" runat="server"

 

 

Text='<%# Bind("create_id") %>'

 

 

Visible="False">

 

 

</asp:TextBox>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td colspan="3">

 

 

<asp:Label ID="lblerror" runat="server" Text="Label"></asp:Label></td>

 

 

</tr>

 

 

</table>

 

 

</FormTemplate>

 

 

</EditFormSettings>

 

 

</MasterTableView>

 

 

<FilterMenu EnableTheming="True" Skin="Hay">

 

 

 

 

 

<CollapseAnimation Duration="200" Type="OutQuint" />

 

 

 

 

 

</FilterMenu>

 

 

 

 

 

</telerik:RadGrid>

 

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 23 Feb 2010, 12:15 PM
Hello Clifford,

More information about how to achieve the desired functionality is available in the following articles:
Referencing controls in grid row/edit form
Accessing Cells and Rows

I hope this gets you started properly.

Sincerely yours,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Clifford Lane
Top achievements
Rank 1
answered on 24 Feb 2010, 12:28 AM
Pavlina:
I had looked over these before posing my question.  The difference and difficulty is that I am trying to get at a textbox that is bound to a data column.  The textbox is in a masteritem template and I am unable to construct the statement needed to get at its content.
0
Accepted
Pavlina
Telerik team
answered on 24 Feb 2010, 03:52 PM
Hi Clifford,

Check out the following online resources and let me know if they help you to achieve your goal:
Custom editors extending auto-generated editors
Grid / Using Server-side API

Best wishes,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Clifford Lane
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Clifford Lane
Top achievements
Rank 1
Share this question
or