• 0

[ASP.NET] Populate data to Datagrid


Question

(About web application)

How to do to search some information and show in a Datagrid? what is the coding?

I'm using M-Access database.

what is the problem for this code?

Dim ds As New DataSet

Dim sql As String = "SELECT SMT_date, SMT_newssort, SMT_title FROM STM_news"

Dim adpt As New OleDb.OleDbDataAdapter(sql, OleDbConnection1)

adpt.Fill(ds)

DataGrid1.DataSource = ds.Tables("STM_news")

DataGrid1.DataBind()

Please help me! Thanks a lot.

Link to comment
https://www.neowin.net/forum/topic/487002-aspnet-populate-data-to-datagrid/
Share on other sites

10 answers to this question

Recommended Posts

  • 0

You haven't named the table, so trying to access it in the Tables collection by name won't work. If you just bind to the dataset, you'll be ok. The datagrid will use the DefaultView.

' DataGrid1.DataSource = ds.Tables("STM_news")
DataGrid1.DataSource = ds
DataGrid1.DataBind()

  • 0
  weenur said:

You haven't named the table, so trying to access it in the Tables collection by name won't work. If you just bind to the dataset, you'll be ok. The datagrid will use the DefaultView.

' DataGrid1.DataSource = ds.Tables("STM_news")
DataGrid1.DataSource = ds
DataGrid1.DataBind()

Sorry, it doesn't work. I have tried so many ways, some like you say the DefaultView, under the windows application it works, but under web application doesn't work.

I don't know what's the problem.

  • 0
  ollie said:

Sorry, it doesn't work. I have tried so many ways, some like you say the DefaultView, under the windows application it works, but under web application doesn't work.

I don't know what's the problem.

Debug and ensure that you're actually returning data. Try writing out the Rows.Count or something to ensure that you are indeed getting a row set back.

  • 0
  weenur said:

Debug and ensure that you're actually returning data. Try writing out the Rows.Count or something to ensure that you are indeed getting a row set back.

Really, thanks a lot for reply me.

I have tried this, I'm sure that some data returning, from the msg it shows there were some rows returned.

but this is nothing in the Datagrid.

help me please..........

  • 0
  ollie said:

Really, thanks a lot for reply me.

I have tried this, I'm sure that some data returning, from the msg it shows there were some rows returned.

but this is nothing in the Datagrid.

help me please..........

Could you post the aspx and vb file, if necessary, so I can look at your grid properties? Just zip 'em up and attach 'em to your post.

  • 0
  ollie said:

Hi, weenur, here are the aspx and vb file.

You're using 2003, aren't you? I no longer have it installed. :pinch:

I think your problem is that you've defined the data source in the designer, and it's overriding your code. Are you getting any data bound to the grid before your button click?

  • 0
  weenur said:

You're using 2003, aren't you? I no longer have it installed. :pinch:

I think your problem is that you've defined the data source in the designer, and it's overriding your code. Are you getting any data bound to the grid before your button click?

Yes, I'm using 2003. and there are some data bound to the grid before button click, any problem?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Windows is a scam for many decades, it's good if some people are realizing it now
    • Latest Patch Tuesday has broken DHCP Server in all Windows Server editions by Usama Jawad Microsoft released Patch Tuesday updates for Windows and Windows Server releases roughly a week ago, on June 10. In the latter, the release contained new functions for Narrator scan mode, along with tons of fixes for File Explorer, GDI+, Hyper-V, and more. At that time, Microsoft noted a known issue for Noto fonts, where Chinese, Japanese, and Korean text appears blurry or unclear under certain conditions. Now, it has highlighted another known issue following user reports. For the past couple of days, users on Reddit have been reporting issues with the DHCP service after applying the latest Patch Tuesday update. Apparently, rebooting the system fixes the issue, which can be understandably annoying. Now, Microsoft has updated the documentation for the June 10 release notes across Windows Server 2016, 2019, 2022, and 2025, to mention that the DHCP Server service may "intermittently" stop working after installing Patch Tuesday's update, which will impact IP renewal processes on client machines. Redmond has assured customers that it is working on a fix, which will likely be rolled out within the next few days. Of course, this problem is rather frustrating for IT admins, and that annoyance is reflected in the Reddit thread where customers are blaming Microsoft's software quality assurance practices. The fact that it's currently unclear when a fix will be rolled out may further add to customer grievances. For those unaware, the DHCP Server service in Windows is responsible for network management such as allocation and configuration of IP addresses in a centralized environment with robust logging and monitoring mechanisms. And for those keeping track, this is not the only Windows Server issue that has cropped up in recent memory. Last month, Microsoft pushed an out-of-band (OOB) hotfix to patch a Hyper-V bug that was plaguing the platform. Of course, one can argue that problems like these are happening because of incomplete testing, but it is also important to remember that Windows is running on hundreds of millions of devices all over the globe, so comprehensive test case coverage is very difficult, if not impossible.
    • And still, no Windows Hello support for protected "tabs" in the "old"/Win32 OneNote app, a feature that was available for a long time in the UWP version. Please, Microsoft, get back to feature parity...
    • Like jupe, for me, the most exciting news from Windows for a few weeks ( / months ?) now is the return of the clock in the taskbar calendar. I filed a feedback hub post so long ago about this. Finally!
  • Recent Achievements

    • Week One Done
      patrickft456 earned a badge
      Week One Done
    • One Month Later
      patrickft456 earned a badge
      One Month Later
    • One Month Later
      Jdoe25 earned a badge
      One Month Later
    • Explorer
      Legend20 went up a rank
      Explorer
    • One Month Later
      jezzzy earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      617
    2. 2
      ATLien_0
      281
    3. 3
      +FloatingFatMan
      174
    4. 4
      Michael Scrip
      153
    5. 5
      Steven P.
      124
  • Tell a friend

    Love Neowin? Tell a friend!