DataGridView playing stubborn. It just wouldn't bind


I have one stubborn data grid view is refusing to display the bound data. i placed a grid view named exhibitgridview and set its datasource to none. then i added a standalone data source that can return columns into the grid but first there data displayed in the grid would be based on a what gets selected from a dropdown list. check it out from the picture below. <img alt="alt text" class="b-lazy" data-src="https://i.stack.imgur.com/6vrFB.jpg" data-original="https://i.stack.imgur.com/6vrFB.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

So basically some item is selected from the dropdown list next to the caseid label and the grid displays values accordingly... AS such i needed a selectedIndexchanged method so i had this in my page.cs

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { CreateDataSet(); caseID = DropDownList1.SelectedItem.Value.Trim(); DataView exhibitDataView = new DataView(exhibitDataSet.Tables[0]); exhibitDataView.RowFilter = "FilingID = '" + caseID + "' "; ExhibitGridView.DataSource = exhibitDataView; ExhibitGridView.DataBind(); } private void CreateDataSet() { exhibitConnection.ConnectionString = ExhibitListSqlDataSource.ConnectionString; exhibitSqlDataAdapter.SelectCommand = new SqlCommand(ExhibitListSqlDataSource.SelectCommand, exhibitConnection); exhibitSqlDataAdapter.Fill(exhibitDataSet); }

The code runs sweet...I inserted a breakpoint as to ensure some data is actually returned for binding and there is...you can see that from the screen shot below: <img alt="alt text" class="b-lazy" data-src="https://i.stack.imgur.com/5BfQV.jpg" data-original="https://i.stack.imgur.com/5BfQV.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

that was until (ExhibitGridView.DataBind()). So when i run the next block, i expect the data to bind and display in the browser but for some unknown reason the gridview is acting stubborn. i tried specifying the datasource directly and it displays successfully at pageload but otherwise it wouldn't respond.

What could be the cause?


I do believe you need to supply your DataAdapter with the parameters that you are supplying your select statement with. Take a look.

I have given you an example from my code which uses OleDB (I have removed all the open / close connection for ease of reading). They are VERY similar.

SqlCmd = "select * from App_Details WHERE App_Name LIKE @Var"; aCommand = new OleDbCommand(SqlCmd, aConnection); aCommand.Parameters.AddWithValue("@Var", value); OleDbDataAdapter dataAdapter = new OleDbDataAdapter(SqlCmd, aConnection); OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(dataAdapter); // Now I do not see this part in your code right before you bind your data dataAdapter.SelectCommand.Parameters.AddWithValue("@Var", value); DataTable table = new DataTable(); dataAdapter.Fill(table); dgvSearchApp.DataSource = table;


Make sure about Post Back events. Maybe the page is doing two post backs.


  • sql query and dropdownlist
  • How do I confirm existence of all respective variables of a variable list?
  • Remove duplication row in gridview
  • Converting an image to base64 in angular 2
  • Change textbox value using dropdown selected in php and mysql
  • Use of Java generics could be hanging the compiler
  • Enable text box based on radio button selected
  • DataGrid: Help accessing a control defined in a CellEditingTemplate
  • Change Font Style (bold, Italic, bold italic) in C# [duplicate]
  • Binding a list with another list with WPF
  • C# “cannot assign field because it is a foreach iteration variable”
  • Bind drop down list with Dictionary
  • Type Native Wifi.Wlan + WlanReasonCode cannot be marshaled error
  • Excel 2007: Format of email address from Outlook 2007
  • Unique SMS sender id?
  • UIBarButtonItem's action is not called when in a view with a UIGestureRecognizer
  • Updating and removing unique join relationships in CakePHP
  • Exception HRESULT: 0x800455BC in speech recognition in Windows phone 8
  • Negating Regex PO BOX
  • How to access recipient on sent messages page with mailboxer
  • Click on button in another program - FindWindow, C#
  • Android device acting as an accessory
  • Switch to popup in python using selenium
  • How to pass a value from ASP.NET MVC controller to ASP.NET webforms control inside MVC View?
  • ASP.NET MVC 2 Preview 2 - display directory list rather than home/index
  • Can't delete or rename original file after resizing
  • Jquery popup on mouse over of calendar control
  • c# open webrowser in many tab
  • Firefox Extension - Monitor refresh and change of tab
  • ADO and msqli connections very slow
  • CakePHP 2.0.4 - findBy magic methods with conditions
  • How to Cache Real-time Data?
  • Highlight one bar in a series in highcharts?
  • DomPDF {PAGE_NUM} not on first page
  • javascript inside java/jsp code
  • htaccess rewriting URLs with multiple forward slashes
  • Display Images one by one with next and previous functionality
  • Web-crawler for facebook in python
  • AT Commands to Send SMS not working in Windows 8.1
  • A cron job substitute?