复选框功能不起作用 [英] Check box function not working

查看:90
本文介绍了复选框功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是收费页面。我有12个12个月的复选框。当我们点击一​​个月然后在文本框中显示的月份费用。但是,如果我们点击两个月怎么办?我想在选中复选框时在文本框中显示两个月或三个月的费用增加或相乘。



aspx代码:

This is a fee collection page. I have 12 check boxes for 12 months. when we click on one month then the fees for the month in shown in the textbox under. But what if we click on two month? I want to show the fees for two months or three months added or multiplied in the textbox when checkbox is checked.

aspx code:

<asp:CheckBoxList ID="cbl" " runat="server" Height="28px"
                           RepeatDirection="Horizontal" RepeatColumns="4" Width="45px"
                           OnInit="cblGenre_Init" AutoPostBack="True" onselectedindexchanged="cbl_SelectedIndexChanged"
                            " Enabled='<%#Eval("status") %>'>

       </asp:CheckBoxList>





cs.aspx代码





cs.aspx code

protected void cbl_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataSet dspmr = obj1.returndataset("SELECT amount FROM fee_head WHERE acc_head='Tution Fee' and  class='" + txt_class.Text.ToString() + "' and adm_session='" + txt_batch.Text.ToString() + "'");

        txt_amount.Text = dspmr.Tables[0].Rows[0]["amount"].ToString();

    }

推荐答案





使用您的代码,如下面的示例代码:



Hi,

Use your code like the following sample code:

SqlCeDataAdapter da = new SqlCeDataAdapter();
DataSet ds = new DataSet();
DataTable dt = new DataTable();

da.SelectCommand = new SqlCommand(@"SELECT * FROM FooTable", connString);
da.Fill(ds, "FooTable");
dt = ds.Tables["FooTable"];

foreach (DataRow dr in dt.Rows)
{
    MessageBox.Show(dr["Column1"].ToString());
}

To read a specific cell in a row:

int rowNum // row number
string columnName = "DepartureTime";  // database table column name
dt.Rows[rowNum][columnName].ToString();





这将解决你的问题。



谢谢



This will resolve your problem.

Thanks


你好,



in此事件cbl_SelectedIndexChanged(object sender,EventArgs e)



a)int maxMonth =用于每个查找最大选定月份值。

b)txt_amount.Text = Convert.ToInt32(dspmr.Tables [0] .Rows [0] [amount])* maxMonth;



查找最大月份:





hi ,

in this event "cbl_SelectedIndexChanged(object sender, EventArgs e)"

a)int maxMonth= Use for each to find the max selected month value .
b)txt_amount.Text = Convert.ToInt32(dspmr.Tables[0].Rows[0]["amount"])* maxMonth;

To find max month :


int maxmonth = 0;
        foreach (ListItem listItem in chbLst.Items)
        {
            if(listItem.Selected)
            {
                maxmonth = Convert.ToInt32(listItem.Value);
            }
        }







<asp:CheckBoxList ID="chbLst" runat="server" OnSelectedIndexChanged="chbLst_OnSelectedIndexChanged" AutoPostBack="true">
           <asp:ListItem Text="1 year" Value="1"></asp:ListItem>
           <asp:ListItem Text="2 year" Value="2"></asp:ListItem>
           <asp:ListItem Text="3 year" Value="3"></asp:ListItem>
           <asp:ListItem Text="4 year" Value="4"></asp:ListItem>
       </asp:CheckBoxList>


I'我没有得到你的信息。我是asp.net的新手。你能帮帮我更多吗?还是精心设计?
I''m not getting you sisir. I''m a newbie in asp.net. Please could you help me more? Or ellaborate?


这篇关于复选框功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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