Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
DataSet dspc = obj.returndataset("select * from commission_master where product_code='" + DropDownList1.SelectedItem.Text.Trim() + "'");
        Label4.Text = dspc.Tables[0].Rows[0]["product_name"].ToString().Trim();

        DataTable dt = obj.returndatatable("select * from term_master where scheme = '" + drp_plan.SelectedValue.ToString().Trim() + "' and nplan = '" + DropDownList1.SelectedItem.Text.Trim() + "' order by slno");
        if (dt.Rows.Count > 0)
        {
            double rdmin, fdmin;
            rdmin = Convert.ToDouble(dt.Rows[0]["rd_min_book_amount"].ToString().Trim());
            fdmin = Convert.ToDouble(dt.Rows[0]["fd_min_book_amount"].ToString().Trim());

            if (rdmin > 0 && fdmin > 0)
            {
                //tr_rdbookamt.Visible = true;
                //tr_fdbookamt.Visible = true;
                txt_fdbookamt.Text = "0";
            }
            else if (rdmin > 0)
            {
                //tr_rdbookamt.Visible = true;

                txt_fdbookamt.Text = "0";
            }
            else
            {
                //tr_fdbookamt.Visible = true;
                txt_rdbookamt.Text = "0";
            }

        }
        else
        {
            lbl_err.Text = "Select Scheme  & Plan !";
        }

        drp_term.Items.Insert(0, "Select");
        drp_term.Focus();
    }
Posted
Updated 17-Jul-12 23:56pm
v3
Comments
Karthik Harve 18-Jul-12 5:36am    
Debug the code and find the row counts of the datatable. then you will find the answer.
Member 9017207 18-Jul-12 5:37am    
How can we do that? Please guide
Pankaj Nikam 18-Jul-12 5:57am    
Please avoid putting the words like urgent. Its urgent for you not for us. Your post may get down votes just because of that.

1 solution

i think you are getting this exception at third line.
Add before this
if(dspc.Tables[0].Rows.Count>0)
{
Label4.Text = dspc.Tables[0].Rows[0]["product_name"].ToString().Trim();
}
else
{
//return from code
//or dont handle that dataset in this part
}
 
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