parameter passing while generating report in ASP.NET

Looks like SSRS ReportViewer control. You have 2 options: If you’re using default SSRS ReportViewer.aspx you can pass parameter through the URL, like that: http:///ReportServer/Pages/ReportViewer.aspx?PathToReport&rs:Command=Render&ExamYear=2013 If you’re using ReportViewer control directly, pass parameter in the codebehind: ReportParameter examYearParam = new ReportParameter(“ExamYear”, 2013); reportViewer1.ServerReport.SetParameters(examYearParam);

From Dictionary to List

Looks like you want to create a new List<string> based on your all string elements in the dictionary’s List values. You may use SelectMany to flatten it out and get a list using the following code: Dictionary<string, List<string>> Dic = new Dictionary<string, List<string>>(); Dic.Add(“1”, new List<string>{“ABC”,”DEF”,”GHI”}); Dic.Add(“2”, new List<string>{“JKL”,”MNO”,”PQR”}); Dic.Add(“3”, new List<string>{“STU”,”VWX”,”YZ”}); List<string> strList = … Read more

How do I create a csv file with the output of sql query?

public string ExportToCSVFile(DataTable dtTable) { StringBuilder sbldr = new StringBuilder(); if (dtTable.Columns.Count != 0) { foreach (DataColumn col in dtTable.Columns) { sbldr.Append(col.ColumnName.Replace(“,”, “”) + ‘,’); } sbldr.Append(“\r\n”); foreach (DataRow row in dtTable.Rows) { foreach (DataColumn column in dtTable.Columns) { sbldr.Append(row[column].ToString().Replace(“,”, “”).Trim() + ‘,’); } sbldr.Append(“\r\n”); } } return sbldr.ToString(); }

c# – How to read an int variable if it's an string

If you just want to read a string, try to convert to an integer, and exit the program if it’s not a valid integer, then you’d use int.TryParse, like this: string input = Console.ReadLine(); if (int.TryParse(input, out x)) { // do something with x } else { // input was invalid. } If you want … Read more