Datagrid not displayed?

Results 1 to 2 of 2

Thread: Datagrid not displayed?

  1. #1
    Join Date
    Dec 1969

    Default Datagrid not displayed?

    Hi,<BR><BR>I have a windows forms application. <BR>I need to do this:<BR>When the Search button is clicked, all the result table contents should be displayed in a datagrid form.<BR>This is not happening with the below code?<BR><BR>I see that the sql stmt is executed but the Datagrid is not to be seen. I know that the sql stmt is executed because I replaced the Select stmt with a Delete stmt and it works perfectly fine.<BR>Hence I want to know how to display the datagrid control.<BR><BR><BR>private void Search_button_Click(object sender, System.EventArgs e)<BR> {<BR> <BR> OleDbConnection conn = new OleDbConnection(xxxxx;Trusted_Connection=yes");<BR > conn.Open();<BR> DataSet ds = new DataSet();<BR><BR> <BR> string sql = "SELECT * FROM CUSTOMER WHERE ID=&#039;2000&#039;";<BR> OleDbDataAdapter adapter1 = new OleDbDataAdapter(sql,conn);<BR> adapter1.Fill(ds,"Customer");<BR> <BR> DataGrid dg1 = new DataGrid();<BR> dg1.DataSource = ds;<BR> dg1.DataMember = "Customer";<BR> dg1.DataSource = ds.DefaultViewManager;<BR> <BR> dg1.Show();<BR><BR> <BR> <BR> }

  2. #2
    Join Date
    Dec 1969

    Default RE: Datagrid not displayed?

    Do you need to call .DataBind??<BR><BR>dg1.DataSource = ds;<BR>dg1.DataMember = "Customer";<BR>dg1.DataSource = ds.DefaultViewManager;<BR>dg1.DataBind<BR><BR>I haven&#039;t worked with Windows forms so I could be wrong!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts