Click here to Skip to main content
15,905,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
'System.Web.UI.MobileControls.List' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'System.Web.UI.MobileControls.List' could be found (are you missing a using directive or an assembly reference?)
My code attached here.
C#
protected void Button2_Click(object sender, EventArgs e) {

    var l = new List();
    sc.Open();
    SqlCommand cmd = new SqlCommand("select Fliono from BOND_REG where status='A'", sc);
    SqlDataReader SDR = cmd.ExecuteReader();


    while (SDR.Read() == true)
    {
        var item1 = SDR.GetValue(0).ToString();
        l.Add(item1);

    }
    fileexport(l);
    updatestaus(l);
    SDR.Close();
    sc.Close();

}

public void updatestaus(List F)
{
    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < F.Items.Count - 2; i++)
    {
        sb.Append(F.Items[i].ToString() + ",");
    }
    sb.Append(F.Items[F.Items.Count - 1].ToString());


    sc.Close();
    sc.Open();
    SqlCommand cmd = new SqlCommand("update BOND_REG set status='P' where fliono IN ('" + sb.ToString() + "')", sc);
    cmd.ExecuteNonQuery();
    sc.Close();
}

public void fileexport(List F)
{
    // SDR.Close(); 
    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < F.Items.Count - 2; i++)
    {
        sb.Append(F.Items[i].ToString() + ",");
    }
    sb.Append(F.Items[F.Items.Count - 1].ToString());


    SqlCommand cmd1 = new SqlCommand("select * from BOND_REG where status='A' and Fliono IN ('" + sb.ToString() + "')", sc);
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd1;
    DataTable datatable = new DataTable();
    da.Fill(datatable);
    ReportDocument crystalReport = new ReportDocument();
    crystalReport.Load(Server.MapPath("~/bond.rpt"));
    crystalReport.SetDataSource(datatable);
    ExportOptions rptExportOption;
    DiskFileDestinationOptions rptFileDestOption = new DiskFileDestinationOptions();
    PdfRtfWordFormatOptions rptFormatOption = new PdfRtfWordFormatOptions();
    string reportFileName = @"C:\pdfd\ st1.pdf";
    rptFileDestOption.DiskFileName = reportFileName;
    rptExportOption = crystalReport.ExportOptions;
    {
        rptExportOption.ExportDestinationType = ExportDestinationType.DiskFile;
        rptExportOption.ExportFormatType = ExportFormatType.PortableDocFormat;
        rptExportOption.ExportDestinationOptions = rptFileDestOption;
        rptExportOption.ExportFormatOptions = rptFormatOption;
    }

    crystalReport.Export();
}
Posted
Updated 31-May-15 21:05pm
v2

List[^] represents a strongly typed list of objects. So, you have to define type of objects you want to store in a list.

C#
List<string> l = new List<string>;
 
Share this answer
 
Don't use "var" until you fully understand types, it also makes giving help harder too. But use the generic version of List

//var l = new List();
List<string> l = new List<string>();
</string></string>
 
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