Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:***

ASP.NET
<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***
C#
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*****
ASP.NET
<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
Updated 16-Dec-12 19:16pm
v3

1 solution

HI,

Change the code to ...

C#
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
 
Share this answer
 
Comments
m_safaaaa 20-Dec-12 2:44am    
hi, thank you but still the same problem
[no name] 20-Dec-12 3:04am    
Can you please check whether there is any value in your branchid.Text.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900