无法检索原始值(下拉列表值)表格的编辑项目的radgrid控件 [英] Cannot Retrieve Original Value (of a dropdown List Value) form Edited Item of a radgrid control

查看:81
本文介绍了无法检索原始值(下拉列表值)表格的编辑项目的radgrid控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,请紧急。



我有一个rad网格控件,显示设施列表。当我点击rad网格的编辑链接时;显示带有编辑项目的Web用户控制页面AddFacility.ascx。



我的问题是如何显示与右侧branchID匹配的下拉列表中正确选择的值( Web用户控制页面AddFacility.ascx中的rad网格字段。



提前谢谢。





*** frmFaility.aspx中的Rad Grid和sql数据源:***



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 * **



****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;
.....
}



*****网页用户控制AddFacility.ascx *****


*****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



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

推荐答案

ConnectionStrings:SmartBookingEngineConn %>\"

S electCommand=\"SELECT [Name], [Description], [Amount], [facilitiesID], [NameAr], [DescriptionAr], [createdDate], [updatedDate],[cityID],[branchID],[city],[Branch] FROM [viewFacilitiesMaster]\">
</asp:SqlDataSource>
ConnectionStrings:SmartBookingEngineConn %>" SelectCommand="SELECT [Name], [Description], [Amount], [facilitiesID], [NameAr], [DescriptionAr], [createdDate], [updatedDate],[cityID],[branchID],[city],[Branch] FROM [viewFacilitiesMaster]"> </asp:SqlDataSource>





****frmFaility.aspx.cs***



****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*****


*****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=\"< span class=\"code-keyword\">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 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();
}
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



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


这篇关于无法检索原始值(下拉列表值)表格的编辑项目的radgrid控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆