问题根据从钻取中选择的方式将数据分配到文本框中 [英] problem assigning data into a text box based on selection from drilldown

查看:72
本文介绍了问题根据从钻取中选择的方式将数据分配到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

带有undernoted的表格





1.支付类型(ddl): ddl_Disburs_Type (正文)



2.批准金额: txt_Expect_Amt (文字)



3 。实际支付: txt_Actual_Disb (文字)





向下钻取(即支付类型)有2项 A。完全b。 TRANCHE



选择 FULL 选项时,程序必须执行以下操作。



但是控制不能切换。



请协助





A form with the undernoted


1. Disbursement Type (ddl) : ddl_Disburs_Type (Text)

2. Amount Approved : txt_Expect_Amt (Text)

3. Actual Disbursement : txt_Actual_Disb (Text)


The Drill down (i.e. Disbursement Type) has 2 items a. FULL b. TRANCHE

When the option FULL is selected the program has to do the following .

However control does not switch over.

please assist


protected void ddl_Disburs_Type_SelectedIndexChanged(object sender, EventArgs e)
     {

         if (ddl_Disburs_Type.Text == "FULL")
         {

             txt_Tranche.Text = "0";
             txt_Tranche.Enabled = false;
             txt_Actual_Disb.Text = txt_Expect_Amt.Text;

             decimal KExpect_Amt = Convert.ToDecimal(txt_Expect_Amt.Text);
             txt_Expect_Amt.Text = KExpect_Amt.ToString("N");

             //decimal KActual_Disb = Convert.ToDecimal(txt_Actual_Disb.Text);
             decimal KActual_Disb = Convert.ToDecimal(txt_Expect_Amt.Text);
             txt_Actual_Disb.Text = KActual_Disb.ToString("N");

推荐答案

您是否尝试调试代码?这应该让你清楚地知道为什么它不起作用。



在MSDN上查看如何使用VS调试ASP.Net Apps:



http://msdn.microsoft.com/en-us/library/w2faa92k.aspx [ ^ ]



另一方面,在这种情况下,无论套管如何,比较字符串总是好的。



而且,我也会将FULL置于常数或者资源字符串而不是魔术字符串 [ ^ ]。



Did you try to debug your code? That should give you a clear idea why it does not work.

Look on MSDN, how to debug ASP.Net Apps using VS:

http://msdn.microsoft.com/en-us/library/w2faa92k.aspx[^]

On another note, it's always good to compare string irrespective of casing in such situations.

And also, I would also put FULL in constant or a resource string instead of a magic string[^].

if(String.Compare(ddl_Disburs_Type.Text, const_resource_Full, true) == 0)
{
    //you logic here
}


除了Manas答案,在ASP.NET DropDownList [ ^ ]不会在所选项目上进行回发。即使你已经添加了 SelectedIndexChanged [ ^ ]事件到您的DropDownList它不会执行它,除非您设置 AutoPostBack [ ^ ]属性为true。示例代码:

apart from Manas Answer, in ASP.NET DropDownList [^]is not postback on selected item change by default. Even you have added SelectedIndexChanged [^]event to your DropDownList it will not excute it unless you set the AutoPostBack [^]Property as true. Sample code :
<asp:dropdownlist id="ColorList" xmlns:asp="#unknown">
                   AutoPostBack="True"
                   OnSelectedIndexChanged="Selection_Change"
                   runat="server"></asp:dropdownlist>



设置上面的属性后,在事件处理程序中放置断点并运行Web应用程序。您可以检查DropdownList的Text属性所接收的值是什么。根据您可以更改代码,它将帮助您找到解决方案,解决您的代码块无法正常运行的原因。

如果您感兴趣,可以使用额外的学习资源进行调试:

掌握Visual Studio 2010中的调试 - 初学者指南 [ ^ ]

Visual Studio中的高级调试 [ ^ ]


这篇关于问题根据从钻取中选择的方式将数据分配到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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