Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
XML
<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 code

C#
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();

    }
Posted
Updated 1-Jan-13 23:37pm
v5
Comments
[no name] 2-Jan-13 5:58am    
hi,

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() + "'");

Can you please let me know whether this query will give you only one month fee ?
Member 9017207 2-Jan-13 6:00am    
Yes one month fee. I want to show values in textbox when I click either two months, three months or more
Member 9017207 2-Jan-13 6:10am    
How to find max selected month value... can u pls write the exact code. I'm a newbie. Pls

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
 
Share this answer
 
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 :


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


XML
<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>
 
Share this answer
 
v2
I'm not getting you sisir. I'm a newbie in asp.net. Please could you help me more? Or ellaborate?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900