问题描述
我创建了一个显示员工详细信息的radgrid。当我尝试插入新员工时,radgrid编辑表单会打开。在那里,我使用两个名为cmb_company和cmb_commercialActivity的radcombobox,并为每个分别使用sqldatasource。
Hi,
i'm created a radgrid which displays employee details. when i'm trying to insert a new employee, the radgrid edit form opens. in that, i'm using two radcombobox named cmb_company and cmb_commercialActivity and seperate sqldatasource for each.
<div class="art-layout-cell layout-item-1" style="width: 100%;">
<div class="art-layout-cell layout-item-4" style="width: 30%;">
<asp:Label ID="label_SelectCompany" AssociatedControlID="cmb_company" runat="server" Text="Company Name:" />
</div>
<div class="art-layout-cell layout-item-4" style="width: 60%;">
<telerik:RadComboBox runat="server" ID="cmb_company" Height="250" AppendDataBoundItems="True" CausesValidation="False" CollapseDelay="10" SelectedValue='<%# Bind("CompanyID") %>'
DataMember="DefaultView" AutoPostBack="true" ExpandDelay="0" ItemRequestTimeout="0" Width="80%" MarkFirstMatch="True" EmptyMessage="- Select Company -"
DataSourceID="SqlDataSource_Company" DataTextField="CompanyName" DataValueField="ID" önSelectedIndexChanged="cmb_company_SelectedIndexChanged" />
<asp:RequiredFieldValidator ID="CompanyRequired" runat="server" ControlToValidate="cmb_company" ErrorMessage="*" ForeColor="Red" ValidationGroup="CompanyGroup" />
</div>
</div> <%-- cmb_company --%>
<div class="art-layout-cell layout-item-1" style="width: 100%;">
<div class="art-layout-cell layout-item-4" style="width: 30%;">
<asp:Label ID="label_CommercialActivity" AssociatedControlID="cmb_commercialActivity" runat="server" Text="Commercail Activity:" />
</div>
<div class="art-layout-cell layout-item-4" style="width: 60%;">
<telerik:RadComboBox runat="server" ID="cmb_commercialActivity" AppendDataBoundItems="True" CausesValidation="False" CollapseDelay="10" DataMember="DefaultView"
ExpandDelay="0" ItemRequestTimeout="0" Width="80%" MarkFirstMatch="True" EmptyMessage="- Select Commercial Activity -" SelectedValue='<%# Bind("EmployeeCommercialActivityID") %>'
DataSourceID="SqlDataSource_CommercialActivity" DataTextField="CommercialActivityEnglishName" DataValueField="ID" />
<%--<asp:RequiredFieldValidator ID="CommercialActivityRequired" runat="server" ControlToValidate="cmb_commercialActivity" ErrorMessage="*" ForeColor="Red" ValidationGroup="CompanyGroup" />--%>
</div>
</div> <%-- cmb_commercialActivity --%>
和sqldatasource
and sqldatasource
<asp:SqlDataSource ID="SqlDataSource_CommercialActivity" runat="server" ConnectionString="<%$ ConnectionStrings:HRSystemDataBaseConnection %>" SelectCommand="SELECT APP_CompaniesCommercialActivities.ID, APP_CommercialActivities.CommercialActivityEnglishName FROM APP_CompaniesCommercialActivities INNER JOIN APP_CommercialActivities ON APP_CompaniesCommercialActivities.CommercialActivityID = APP_CommercialActivities.ID WHERE (APP_CompaniesCommercialActivities.CompanyID = @CompanyID) ORDER BY APP_CommercialActivities.CommercialActivityEnglishName">
<SelectParameters>
<asp:SessionParameter Name="CompanyID" SessionField="CompanyID" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource_Company" runat="server" ConnectionString="<%$ ConnectionStrings:HRSystemDataBaseConnection %>"
SelectCommand="SELECT ID, CompanyName FROM APP_Companies ORDER BY CompanyName" />
和代码隐藏是
and codebehind is
protected void cmb_company_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
Session["CompanyID"] = e.Value;
}
当我更改公司时,会话值已更改,并且报告错误
数据绑定方法,如Eval(),XPath()和Bind()只能在数据绑定控件的上下文中使用。
at cmb_commercialActivity。
问候,
rafsan
when i change the company, the session value is changed, and error is reporting
"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."
at cmb_commercialActivity.
Regards,
rafsan
推荐答案
和代码隐藏是
and codebehind is
protected void cmb_company_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
Session["CompanyID"] = e.Value;
}
当我更改公司时,会话值已更改,并且报告错误
数据绑定方法,如Eval(),XPath()和Bind()只能在数据绑定控件的上下文中使用。
at cmb_commercialActivity。
问候,
rafsan
when i change the company, the session value is changed, and error is reporting
"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."
at cmb_commercialActivity.
Regards,
rafsan
Session["CompanyID"] = cmb_company.SelectedValue
这篇关于会话值更改时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!