Click here to Skip to main content
Rate this: bad
good
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" 
            OnNeedDataSource="RadGrid1_NeedDataSource" 
            OnUpdateCommand="RadGrid1_UpdateCommand" 
            OnInsertCommand="RadGrid1_InsertCommand" 
            OnDeleteCommand="RadGrid1_DeleteCommand" Skin="Black" 
        ShowGroupPanel="True"  önitemcommand="gvS_ItemCommand">  
<MasterTableView autogeneratecolumns="False" datasourceid="tblFacilities"
EditMode="PopUp" commanditemdisplay="Top" >
 <Columns>
 <telerik:GridBoundColumn DataField="cityID" HeaderText="City ID" 
            SortExpression="cityID" UniqueName="cityID" Visible="true">
        </telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="branchID" HeaderText="Branch ID" 
            SortExpression="branchID" UniqueName="branchID" Visible="true">
        </telerik:GridBoundColumn>
 </Columns>
 <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>
</EditFormSettings>
</MasterTableView>
 <ClientSettings AllowDragToGroup="True"></ClientSettings>              
<FilterMenu EnableTheming="True">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</FilterMenu>
</telerik:RadGrid>
 <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]">
</asp:SqlDataSource>
 
 
****frmFaility.aspx.cs***
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*****
<tr>
 <td width="25%">
            <asp:Label ID="Label2" runat="server" Text=" Hotel City"></asp:Label>
 </td>
 <td width="75%">   
            <asp:DropDownList ID="ddlCity" runat="server" DataSourceID="tblCity" DataTextField="city" DataValueField="cityID" AutoPostBack="true">
            </asp:DropDownList>
            <asp:SqlDataSource ID="tblCity" runat="server" ConnectionString="<% $ ConnectionStrings:SmartBookingEngineConn %>" SelectCommand="select cityID,city from viewCityAdmin"></asp:SqlDataSource>
 </td>
</tr>
 
<tr>
  <td width="25%">
            <asp:Label ID="Label3" runat="server" Text=" Hotel Branch"></asp:Label>
  </td>
  <td width="75%">
           <asp:DropDownList ID="ddlBranch" runat="server" DataSourceID="tblBranch" 
                DataTextField="Branch" DataValueField="BranchID">
           
            </asp:DropDownList>
 
            <asp:SqlDataSource ID="tblBranch" runat="server" ConnectionString="<%$ ConnectionStrings:SmartBookingEngineConn %>" SelectCommand="SELECT [BranchID],[Branch] FROM [tblBranch] WHERE ([CityID]=@cityID)">
               <SelectParameters>
                <asp:ControlParameter Name="cityID" ControlID="ddlCity" PropertyName="SelectedValue" Type="String" />
               </SelectParameters>
            </asp:SqlDataSource> 
 
<telerik:RadTextBox ID="cityid"  runat="server" Height="28px" Visible="false"  Text='<%# DataBinder.Eval( Container, "DataItem.cityID"  ) %>' >
            </telerik:RadTextBox>
        </td>
      </tr>
      <tr>
        <td width="35%">
            <telerik:RadTextBox ID="usertypeid"  runat="server" Height="28px" Visible="false">
            </telerik:RadTextBox>
  </td>
</tr>
 
/pre>      
 
*****Web User Control AddFacility.ascx.cs*****  
<pre lang="c#">
protected void Page_Load(object sender, EventArgs e)
{
tblBranch.SelectCommand = "Select * from tblBranch where BranchID=@branchid";
tblBranch.SelectParameters.Clear();
tblBranch.SelectParameters.Add("branchid", branchid.Text.ToString());
tblBranch.DataBind();
}
 
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
Edited 16-Dec-12 20:16pm
v3

1 solution

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

Solution 1

HI,
 
Change the code to ...
 
protected void Page_Load(object sender, EventArgs e)
{
tblBranch.SelectCommand = "Select * from tblBranch where BranchID="+ branchid.Text.ToString();
tblBranch.SelectParameters.Clear();
tblBranch.SelectParameters.Add("branchid", branchid.Text.ToString());
tblBranch.DataBind();
}
 
Ttry like this and check.
 
Thanks
  Permalink  
Comments
m_safaaaa at 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
0 OriginalGriff 250
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 DamithSL 125
4 Afzaal Ahmad Zeeshan 120
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2014
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