• 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 10 KB5062649 fixes Extended Security bug, unresponsive systems, and more by Sayan Sen Microsoft has released today the non-security preview update (also known as the C-release) for Windows 10. The update, under KB5062649 and Build 19045.6159, fixes some major bugs including one for Extended Security Updates (ESU), unresponsive systems, Secure Boot, and more. Since this is a preview update for next month's Patch Tuesday it is an optional release. Microsoft says that users reported that the ESU wizard would not work correctly when they tried to use the option to extend support for Windows 10 for another year; this bug should be fixed now. The company has also fixed "stability issues" with this release as it resolves problems in the core file system. Affected users reported unresponsive systems since the May 2025 Patch Tuesday. There are other improvements as well. The full changelog is given below: ​​​​​[Extended Security Updates] Fixed: An issue impacting the Windows 10 Extended Security Updates (ESU) enrollment wizard. Some users experienced a problem where clicking “Enroll now” caused the wizard window to open, begin loading, and then close unexpectedly. This occurred due to incomplete app registration, which prevented the wizard from loading correctly. This update addresses that issue to ensure a smoother enrollment experience. [Mobile Operator Profiles] Updated: Country and Operator Settings Asset (COSA) profiles. [Secure Boot] New! Adds the ability to deploy SKUSiPolicy VBS Anti-rollback protections through the Secure Boot AvailableUpdates registry key. [Core File Systems] Fixed: An issue observed in rare cases after installing the May 2025 security update and subsequent updates causing devices to experience stability issues. Some devices became unresponsive and stopped responding in specific scenarios. [Input] Fixed: A known issue with the Microsoft Changjie Input Method. Users were unable to select words after a recent update. Fixed: A known issue when searching for an emoji in the emoji panel. After a recent update, the search always returns no results. Fixed: An issue in which phonetic input methods, including the Hindi Phonetic Input keyboard and Marathi Phonetic keyboard do not work correctly after a recent update. You can find the official support article here on Microsoft's website.
    • Are there any foldable phones where you can't actually see where the hinge is on the screen? If not, I definitely will never use one until that's possible. That makes the camera cutout look good by comparison.
    • Recall has a completely different purpose and feature-set than Timeline though. It shares some similarities, sure, but Recall isn't an evolved version of Timeline.
    • Yeesh, still a privacy nightmare.
    • That doesn't contradict what I said though. I benchmarked some games some time ago and the actual performance hit came from VBS, not HyperV. With HVCI off, VBS was only knocking off a few FPS on average for me.
  • Recent Achievements

    • Week One Done
      SmileWorks Dental earned a badge
      Week One Done
    • Community Regular
      vZeroG went up a rank
      Community Regular
    • Collaborator
      Snake Doc earned a badge
      Collaborator
    • Week One Done
      Snake Doc earned a badge
      Week One Done
    • One Month Later
      Johnny Mrkvička earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      593
    2. 2
      Michael Scrip
      197
    3. 3
      ATLien_0
      193
    4. 4
      +FloatingFatMan
      131
    5. 5
      Xenon
      122
  • Tell a friend

    Love Neowin? Tell a friend!