Could DataGridView be this dumb? or its me?lol
- by Selase
Am trying to bind data to a dropdown list on pageload based on a condition. Code explains further below.
public partial class AddExhibit : System.Web.UI.Page
{
string adminID, caseIDRetrieved;
DataSet caseDataSet = new DataSet();
SqlDataAdapter caseSqlDataAdapter = new SqlDataAdapter();
string strConn = WebConfigurationManager.ConnectionStrings["CMSSQL3ConnectionString1"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
adminID = Request.QueryString["adminID"];
caseIDRetrieved = Request.QueryString["caseID"];
if (caseIDRetrieved != null)
{
CaseIDDropDownList.Text = caseIDRetrieved;
//CaseIDDropDownList.Enabled = false;
}
else
{
try
{
CreateDataSet();
DataView caseDataView = new DataView(caseDataSet.Tables[0]);
CaseIDDropDownList.DataSource = caseDataView;
CaseIDDropDownList.DataBind();
}
catch (Exception ex)
{
string script = "<script>alert('" + ex.Message + "');</script>";
}
}
}
The CreateDataset method that is called in the if..else statement is contains the following code.
private void CreateDataSet()
{
SqlConnection caseConnection = new SqlConnection(strConn);
caseSqlDataAdapter.SelectCommand = new SqlCommand("Select CaseID FROM Cases", caseConnection);
caseSqlDataAdapter.Fill(caseDataSet);
}
However when i load the page and as usual the condition that is supposed to bid the data is met, the gridview decides to displays as follows...
IS IT ME OR ITS THE DATAGRID?...??