I defined a function in asp.net and assigned this function to a Button click. In this function I have fetched a column from SQL server and assigned its values to a string variable. I want to see the value of this string.
Is there anyway in C# through which i can print the value of this string?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace Uma_Trial_2
{
public partial class Trial1 : System.Web.UI.Page
{
public string final;
protected string Page_Load(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
// {
// if (IsPostBack)
//Initial is !IsPostBack
// {
// BindData();
// }
// }
//protected string BindData(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
DropDownList ddlMul = new DropDownList();
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(@"Data Source=xxxxxxxx;Initial Catalog=xxxxx;Persist Security Info=True;User ID=XXXXX;Password=XXXXXX@$$w0rd");
conn.Open();
string cmdstr = "select DISTINCT [Month_Abbr] from [XXXXXXXXXXXX]";
SqlDataAdapter adp = new SqlDataAdapter(cmdstr, conn);
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
ddlMul = (DropDownList)e.Row.FindControl("DropDownMultiple1");
if (ddlMul != null)
{
ddlMul.DataSource = ds.Tables[0];
ddlMul.DataTextField = ds.Tables[0].Columns["Month_Abbr"].ColumnName.ToString();
ddlMul.DataValueField = ds.Tables[0].Columns["Month_Abbr"].ColumnName.ToString();
ddlMul.DataBind();
}
}
List<String> Month_Abbr_list = new List<string>();
foreach (System.Web.UI.WebControls.ListItem item in ddlMul.Items)
{
if (item.Selected)
{
Month_Abbr_list.Add(item.Value);
}
}
final = "(" + String.Join(",", Month_Abbr_list.ToArray()) + ")";
return final;
}
}
}