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

Find control in EditFormSettings on client side

1 Answer 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Al asked on 04 Sep 2008, 04:47 AM

Hello,


I would like to find the textboxes in my editformsettings on the client side. Basically, I want to be able to press a button (e.g. Geocode) during editing to lookup a value. After selecting the right value from the list, I want it to update the textbox(s) appropriately. Initially, I did it via brute force for one row: document.getElementById('RadGrid1_ctl01_ctl05_tbCity').value = 'yada';

Now with multiple rows, I can't do this. How do I get the name of the textbox generated in my editform. Any insight?

Thanks in advance,
Albert Gorup


<

rad:RadGrid ID="RadGrid1"

runat="server" AutoGenerateColumns="False"

GridLines="None" Skin="FFCIGreen"

ShowStatusBar="True"

EnableAJAXLoadingTemplate="True"

OnUpdateCommand="RadGrid1_UpdateCommand"

OnInsertCommand="RadGrid1_InsertCommand"

OnSelectedIndexChanged="RadGrid1_OnSelectedIndexChanged"

PageSize="10" Width="100%">

<ClientSettings>

<Selecting AllowRowSelect="True"></Selecting>

</ClientSettings>

<AJAXLoadingTemplate>

<div >Loading....</div>

</AJAXLoadingTemplate>

<MasterTableView DataKeyNames="AddressID" AutoGenerateColumns="false" EditMode="EditForms" CommandItemDisplay="Top" >

<Columns>

<rad:GridButtonColumn UniqueName="SelectCommandColumn" CommandName="Select" Text="Select"

HeaderText="Select">

</rad:GridButtonColumn>

<rad:GridButtonColumn UniqueName="EditCommandColumn" CommandName="Edit" Text="Edit"

HeaderText="Edit">

</rad:GridButtonColumn>

<rad:GridBoundColumn DataField="AddressID" HeaderText="AddressID" SortExpression="AddressID"

UniqueName="AddressID" Visible="false">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataField="StreetAddress" HeaderText="StreetAddress" SortExpression="StreetAddress"

UniqueName="StreetAddress">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataField="StreetAddress2" HeaderText="StreetAddress2" SortExpression="StreetAddress2"

UniqueName="StreetAddress2" Visible="false">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City" UniqueName="City">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataField="StateCD" HeaderText="StateCD" SortExpression="StateCD"

UniqueName="StateCD">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataField="ZipCode" HeaderText="ZipCode" SortExpression="ZipCode"

UniqueName="ZipCode">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataField="GeoCode" HeaderText="GeoCode" SortExpression="GeoCode"

UniqueName="GeoCode" Visible="false">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataField="County" HeaderText="County" SortExpression="County"

UniqueName="County" Visible="false">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataField="CountryCD" HeaderText="CountryCD" SortExpression="CountryCD"

UniqueName="CountryCD" Visible="false">

</rad:GridBoundColumn>

</Columns>

<RowIndicatorColumn Visible="True">

<HeaderStyle Width="20px" />

</RowIndicatorColumn>

<PagerStyle NextPageText="Next" PrevPageText="Prev" Mode="NextPrevAndNumeric" Position="Bottom" >

</PagerStyle>

<EditFormSettings EditFormType="Template" >

<FormTemplate>

<table>

<tr>

<td>

Address:

</td>

<td>

<asp:TextBox ID="tbStreetAddress" runat="server" Text='<%# Bind( "StreetAddress" ) %>'>

</asp:TextBox></td>

</tr>

<tr>

<td>

Address #2:

</td>

<td>

<asp:TextBox ID="tbStreetAddress2" runat="server" Text='<%# Bind( "StreetAddress2" ) %>'>

</asp:TextBox></td>

</tr>

<tr>

<td>

City:

</td>

<td>

<asp:TextBox ID="tbCity" runat="server" Text='<%# Bind( "City" ) %>'>

</asp:TextBox></td>

</tr>

<tr>

<td>

State:

</td>

<td>

<asp:DropDownList id="ddStateCD" runat="server" SelectedIndex='<%# GetSelIndex(DataBinder.Eval( Container, "DataItem.StateCD" )) %>'>

<asp:ListItem Value="">&nbsp;</asp:ListItem>

<asp:ListItem Value="AA">ALABAMA</asp:ListItem>

<asp:ListItem Value="AK">ALASKA</asp:ListItem>

<asp:ListItem Value="AR">ARIZONA</asp:ListItem>

<asp:ListItem Value="AK">ARKANSAS</asp:ListItem>

<asp:ListItem Value="CA">CALIFORNIA</asp:ListItem>

<asp:ListItem Value="CO">COLORADO</asp:ListItem>

<asp:ListItem Value="CT">CONNECTICUT</asp:ListItem>

<asp:ListItem Value="DE">DELAWARE</asp:ListItem>

<asp:ListItem Value="DC">DISTRICT OF COLUMBIA</asp:ListItem>

<asp:ListItem Value="FL">FLORIDA</asp:ListItem>

<asp:ListItem Value="GA">GEORGIA</asp:ListItem>

<asp:ListItem Value="HA">HAWAII</asp:ListItem>

<asp:ListItem Value="ID">IDAHO</asp:ListItem>

<asp:ListItem Value="IL">ILLINOIS</asp:ListItem>

<asp:ListItem Value="IN">INDIANA</asp:ListItem>

<asp:ListItem Value="IO">IOWA</asp:ListItem>

<asp:ListItem Value="KA">KANSAS</asp:ListItem>

<asp:ListItem Value="KE">KENTUCKY</asp:ListItem>

<asp:ListItem Value="LA">LOUISIANA</asp:ListItem>

<asp:ListItem Value="MA">MAINE</asp:ListItem>

<asp:ListItem Value="MD">MARYLAND</asp:ListItem>

<asp:ListItem Value="MA">MASSACHUSETTS</asp:ListItem>

<asp:ListItem Value="MI">MICHIGAN</asp:ListItem>

<asp:ListItem Value="MN">MINNESOTA</asp:ListItem>

<asp:ListItem Value="MS">MISSISSIPPI</asp:ListItem>

<asp:ListItem Value="MO">MISSOURI</asp:ListItem>

<asp:ListItem Value="MT">MONTANA</asp:ListItem>

<asp:ListItem Value="NE">NEBRASKA</asp:ListItem>

<asp:ListItem Value="NV">NEVADA</asp:ListItem>

<asp:ListItem Value="NH">NEW HAMPSHIRE</asp:ListItem>

<asp:ListItem Value="NJ">NEW JERSEY</asp:ListItem>

<asp:ListItem Value="NM">NEW MEXICO</asp:ListItem>

<asp:ListItem Value="NY">NEW YORK</asp:ListItem>

<asp:ListItem Value="NC">NORTH CAROLINA</asp:ListItem>

<asp:ListItem Value="ND">NORTH DAKOTA</asp:ListItem>

<asp:ListItem Value="OH">OHIO</asp:ListItem>

<asp:ListItem Value="OK">OKLAHOMA</asp:ListItem>

<asp:ListItem Value="OR">OREGON</asp:ListItem>

<asp:ListItem Value="PE">PENNSYLVANIA</asp:ListItem>

<asp:ListItem Value="RI">RHODE ISLAND</asp:ListItem>

<asp:ListItem Value="SC">SOUTH CAROLINA</asp:ListItem>

<asp:ListItem Value="SD">SOUTH DAKOTA</asp:ListItem>

<asp:ListItem Value="TN">TENNESSEE</asp:ListItem>

<asp:ListItem Value="TX">TEXAS</asp:ListItem>

<asp:ListItem Value="UT">UTAH</asp:ListItem>

<asp:ListItem Value="VE">VERMONT</asp:ListItem>

<asp:ListItem Value="VI">VIRGINIA</asp:ListItem>

<asp:ListItem Value="WA">WASHINGTON</asp:ListItem>

<asp:ListItem Value="WV">WEST VIRGINIA</asp:ListItem>

<asp:ListItem Value="WI">WISCONSIN</asp:ListItem>

<asp:ListItem Value="WY">WYOMING</asp:ListItem>

</asp:DropDownList>

</td>

</tr>

<tr>

<td>

Zip Code:

</td>

<td>

<asp:TextBox ID="tbZipCode" runat="server" Text='<%# Bind( "ZipCode" ) %>'>

</asp:TextBox>

</td>

</tr>

<tr>

<td>

County:

</td>

<td>

<asp:TextBox ID="tbCounty" runat="server" Text='<%# Bind( "County" ) %>'>

</asp:TextBox>

</td>

</tr>

<tr>

<td>

Geo Code:

</td>

<td>

<asp:TextBox ID="tbGeoCode" runat="server" Text='<%# Bind( "GeoCode" ) %>'>

</asp:TextBox>&nbsp;<input type="button" onclick="javascript:GeoCodeLookup()" id="btnGeoCodeLookUp" value="GeoCode"/>

</td>

</tr>

<tr>

<td align="right" colspan="2">

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

runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>

</asp:Button>&nbsp;

<

asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"

CommandName

="Cancel"></asp:Button></td>

</tr>

</table>

</FormTemplate>

</EditFormSettings>

</MasterTableView>

</rad:RadGrid>

1 Answer, 1 is accepted

Sort by
-1
Shinu
Top achievements
Rank 2
answered on 04 Sep 2008, 05:04 AM
Hi,

Go through the following code library submissions and see whether it helps.

Retrieving grid editor value client side
Accessing server controls in a grid template on the client

Shinu.

Tags
Grid
Asked by
Al
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or