0

I am using the aspx combo box selected value to display the gridview data in the popup window. Inside the popup window grid is displaying required data based on the selected value from the aspxcombobox. In that gridview title panel i am using one button to export the grid view data into excel format. I wrote server side onclick event for that button to export the grid into excel with the help of ASPxGridViewExporter. It is exporting into excel format. But, I want to customize an excel file name like SampleGrid_ComboboxSelectedValue_Value.xlsx(SampleGrid_ComboboxSelectedValue_Goods.xlsx), for that i am trying to get which combo box value is selected. I tired to get the combo box selected value inside the button on click event, I am unable to get the value in that event it is getting null value only and throwing an exception like:

An exception of type System.NullReferenceException occurred in Project . dll but was not handled in user code

I am using callback for binding combo box and whenever the grid is binding through the callback the combo box showing null value only. How to get the combo box selected value in Button on click event, Please give me the solution to resolve.

sujith karivelil
  • 28,671
  • 6
  • 55
  • 88
MNK
  • 121
  • 1
  • 2
  • 13
  • Hi Nithya, Welcome to SO. It would be great if you include the code that causing the error. Code can spoke more that words here. And care to read [this thread](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it), definitely you will get an idea about the exception – sujith karivelil Nov 30 '16 at 05:18

1 Answers1

0

No clear with your code. Hope this is what you are looking for.

private void FillDropDownList()
    {
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);

    SqlCommand cmd = new SqlCommand("Select * from students", con);

    SqlDataAdapter da = new SqlDataAdapter(cmd);

    DataSet ds = new DataSet();
    da.Fill(ds);

    DropDownList1.DataTextField = ds.Tables[0].Columns["FullName"].ToString();
    DropDownList1.DataValueField = ds.Tables[0].Columns["id"].ToString();

    DropDownList1.DataSource = ds.Tables[0];
    DropDownList1.DataBind();
}
user777
  • 77
  • 1
  • 1
  • 10