- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的网页中有一个RadGrid,其中有4个字段:
1)公司列表(下拉列表)
2)金额(文本框)
3) 备注(文本框)
公司下拉列表下的数据如下:
TX - 需要 0% 的税
GRE - 需要 11% 的税
EP - 需要 0% 的税
BL - 需要 6% 的税
TL - 需要 0% 的税
要求 1:
在更改 Dropdown 值时,同时“添加新记录”并且当“编辑”记录时,“金额”和“备注”文本框变为空。
为此,我尝试放入“DropDown_SelectedIndexChanged”事件代码但是由于我的 RadGrid 在 asp:FormView 中,所以我的页面从不回发我从 RadGrid 中重新选择项目,代码不起作用
要求 2:
如果 Dropdown 在所选项目中有 0%(text),则“Amount”文本框应该在文本框中使用 0.00 值禁用。
为此,我尝试了以下代码:
protected void rggst_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item as GridEditableItem;
DropDownList list = item.FindControl("ddlCompany") as DropDownList;
list.DataTextField = "TaxDescription";
list.DataValueField = "TaxId";
list.DataSource = IPRRequest.DLTaxCode(CorporateGroupId);
list.DataBind();
if (list.Items.FindByValue("0%"))
{
if (e.Item is GridEditFormInsertItem)
{
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
TextBox txt = (TextBox)insertItem["Amount"].Controls[0];
txt.Text = "0.00";
txt.Enabled = false;
}
}
}
}
但每次我都遇到以下错误:
无法将类型“System.Web.UI.WebControls.ListItem”隐式转换为“bool”
下面是我用于 RadGrid 的 HTML 和 C# 代码:
<asp:FormView ID="fvIPRForm" runat="server" DefaultMode="Insert" DataKeyNames="RequestID" DataSourceID="odsIPRForm" EnableModelValidation="True" OnItemInserting="fvIPRForm_ItemInserting" OnDataBound="fvIPRForm_DataBound" OnItemUpdating="fvIPRForm_Updating" OnItemCommand="fvIPRForm_ItemCommand">
<InsertItemTemplate>
<asp:Panel ID="pnlApprover" runat="server" Visible="true">
<telerik:RadMultiPage ID="RadMultiPage3" runat="server" SelectedIndex="0" Width="100%">
<telerik:RadPageView ID="RadPageView1" runat="server" Width="100%">
<telerik:RadAjaxPanel ID="Main" runat="server">
<telerik:RadGrid ID="RGGST" runat="server" AutoGenerateColumns="false"
ShowStatusBar="true" EnableEmbeddedSkins="true" Skin="Outlook" ShowFooter="True"
OnItemDataBound="rggst_ItemDataBound"
OnInsertCommand="rggst_InsertCommand" OnUpdateCommand="rggst_UpdateCommand"
OnDeleteCommand="rggst_DeleteCommand" OnNeedDataSource= "rggst_NeedDataSource">
<mastertableview commanditemdisplay="Top" autogeneratecolumns="false" datakeynames="Amount"
insertitempageindexaction="ShowItemOnCurrentPage" ShowFooter="True" >
<CommandItemSettings AddNewRecordText="New" />
<Columns>
<telerik:GridEditCommandColumn UniqueName="imagebutton1" ButtonType="ImageButton"></telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn UniqueName="Company" HeaderText="Company">
<ItemTemplate>
<asp:Label ID="lblCompany" Text='<%# Eval("Company") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlCompany" runat="server"/>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn aggregate="SUM" DataField="Amount" HeaderText="Amount" FooterAggregateFormatString="Total : {0:###,##0.00}"
UniqueName="Amount" SortExpression="Amount" DataFormatString="{0:n}"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Remark" HeaderText="Remark"
UniqueName="Remark" SortExpression="Remark" maxlength ="30"></telerik:GridBoundColumn>
<telerik:GridButtonColumn ConfirmText="Delete this Tax Code?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="160px" ConfirmDialogWidth="250px">
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings>
<EditColumn ButtonType="ImageButton" />
</EditFormSettings>
<PagerStyle AlwaysVisible="True" PageSizeControlType="RadComboBox" />
</mastertableview>
</telerik:RadGrid>
</telerik:RadAjaxPanel>
</telerik:RadPageView>
</telerik:RadMultiPage>
</asp:Panel>
</InsertItemTemplate>
<EditItemTemplate>
//same RadGrid in this section
</EditItemTemplate>
<ItemTemplate>
//same RadGrid in this section
</ItemTemplate>
</asp:FormView>
这是我为要求 1 尝试的代码:
protected void ddlTaxCodes1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList taxCodesList = (DropDownList)sender;
GridEditableItem item = (GridEditableItem)taxCodesList.NamingContainer;
string grossAmountTxt = (item["LIGrossAmt"].Controls[0] as TextBox).Text;
string TaxAmt = (item["LITaxAmt"].Controls[0] as TextBox).Text;
string TaxableAmt = (item["LITaxableAmt"].Controls[0] as TextBox).Text;
string Description = (item["LIDescription"].Controls[0] as TextBox).Text;
grossAmountTxt = "";
TaxAmt = "";
TaxableAmt = "";
Description = "";
}
请让我知道我在代码中犯了什么错误。
请注意,我是 Telerik 的新手。提前致谢。
最佳答案
下面是我为我的要求创建的示例代码,并且可以很好地满足上述要求。
此外,asp:FormView 不会影响 SelectdIndexChanged 事件代码,一切正常。
protected void ddlTaxCodes1_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlAcCode.SelectedValue != null || ddlAcCode.SelectedValue != "")
{
ddlAcCode.Enabled = false;
string selItem = ddlAcCode.SelectedItem.Text;
if (selItem.Contains("0%"))
{
txtAmount.Text = "0.00";
txtAmount.Enabled = false;
txtRemark.Text = "";
}
else
{
txtAmount.Text = "";
txtRemark.Text = "";
}
}
}
关于c# - RadGrid,dropDown SelectedIndexChanged 事件在 asp FormView 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31645834/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!