Click here to Skip to main content
12,820,914 members (32,522 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hello, Please it's urgent.

i have a rad grid controls that display a list a facilities. When i click on the Edit link of the rad grid ; a Web User Control page "AddFacility.ascx" with edited items is displayed.

My problem is how to display the right selected value of a dropdownlist matching the right branchID(a field of the rad grid) in the web user control page "AddFacility.ascx" .

thank you in advance.

***Rad Grid and sql data source in frmFaility.aspx:***

<telerik:RadGrid ID="gvS"  runat="server" DataSourceID="tblFacilities" 
     GridLines="None" AllowPaging="True" AllowSorting="True" 
            Width="99%" AutoGenerateColumns="False"
            ShowStatusBar="True" OnPreRender="RadGrid1_PreRender" 
            OnDeleteCommand="RadGrid1_DeleteCommand" Skin="Black" 
        ShowGroupPanel="True"  önitemcommand="gvS_ItemCommand">  
<MasterTableView autogeneratecolumns="False" datasourceid="tblFacilities"
EditMode="PopUp" commanditemdisplay="Top" >
 <telerik:GridBoundColumn DataField="cityID" HeaderText="City ID" 
            SortExpression="cityID" UniqueName="cityID" Visible="true">
         <telerik:GridBoundColumn DataField="branchID" HeaderText="Branch ID" 
            SortExpression="branchID" UniqueName="branchID" Visible="true">
 <EditFormSettings UserControlName="addFacilityForm.ascx"   EditFormType="WebUserControl" CaptionFormatString=" Add Facility Form" FormStyle-Font-Bold=true >
   <FormStyle Font-Bold="True"></FormStyle>
   <PopUpSettings Width="70%" />
   <EditColumn UniqueName="EditCommandColumn1"></EditColumn>
 <ClientSettings AllowDragToGroup="True"></ClientSettings>              
<FilterMenu EnableTheming="True">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
 <asp:SqlDataSource ID="tblFacilities" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SmartBookingEngineConn %>"        
        SelectCommand="SELECT [Name], [Description], [Amount], [facilitiesID], [NameAr], [DescriptionAr], [createdDate], [updatedDate],[cityID],[branchID],[city],[Branch] FROM [viewFacilitiesMaster]">

protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
GridEditableItem editedItem = e.Item as GridEditableItem.EditFormUserControl userControl = UserControl)e.Item.FindControlGridEditFormItem.EditFormUserControlID);
string branchID = (userControl.FindControl("branchid") as RadTextBox).Text;

*****Web User Control AddFacility.ascx*****
 <td width="25%">
            <asp:Label ID="Label2" runat="server" Text=" Hotel City"></asp:Label>
 <td width="75%">   
            <asp:DropDownList ID="ddlCity" runat="server" DataSourceID="tblCity" DataTextField="city" DataValueField="cityID" AutoPostBack="true">
            <asp:SqlDataSource ID="tblCity" runat="server" ConnectionString="<% $ ConnectionStrings:SmartBookingEngineConn %>" SelectCommand="select cityID,city from viewCityAdmin"></asp:SqlDataSource>

  <td width="25%">
            <asp:Label ID="Label3" runat="server" Text=" Hotel Branch"></asp:Label>
  <td width="75%">
           <asp:DropDownList ID="ddlBranch" runat="server" DataSourceID="tblBranch" 
                DataTextField="Branch" DataValueField="BranchID">

            <asp:SqlDataSource ID="tblBranch" runat="server" ConnectionString="<%$ ConnectionStrings:SmartBookingEngineConn %>" SelectCommand="SELECT [BranchID],[Branch] FROM [tblBranch] WHERE ([CityID]=@cityID)">
                <asp:ControlParameter Name="cityID" ControlID="ddlCity" PropertyName="SelectedValue" Type="String" />

<telerik:RadTextBox ID="cityid"  runat="server" Height="28px" Visible="false"  Text='<%# DataBinder.Eval( Container, "DataItem.cityID"  ) %>' >
        <td width="35%">
            <telerik:RadTextBox ID="usertypeid"  runat="server" Height="28px" Visible="false">


the problem is that the textbox branchid is displaying the right edited item from the rad grid, but nothing is displayed on the dropdown list ddlBranch
Posted 12-Dec-12 21:15pm
Updated 16-Dec-12 20:16pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Change the code to ...

protected void Page_Load(object sender, EventArgs e)
tblBranch.SelectCommand = "Select * from tblBranch where BranchID="+ branchid.Text.ToString();
tblBranch.SelectParameters.Add("branchid", branchid.Text.ToString());

Ttry like this and check.

m_safaaaa 20-Dec-12 2:44am
hi, thank you but still the same problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100