Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Morning,

 

I'm currently working on a web app that utilizes the datagrid data component. So, first I created a table, inserted a few textboxes, labels and one datagrid. I then edited the columns for the datagrid using the propoerties manager. Lastly, I added the following code to bind the data to the datagrid:

 


Private Sub Page_Load

     connstr = ConfigurationSettings.AppSettings("DBBASE")
     myConn = New OleDbConnection(connstr)
     ODA = New OleDbDataAdapter("Select * From LifeTable", myConn)
     ODA.Fill(ds, "Life Offer")
     dgQuote.Datasource = ds
     dgQuote.DataBind()

End Sub

 

As you can see dgQuote is my datagrid but I wish to know two things:

 

1. When the page loads, the datagrid displays but the textboxes and labels are not visible (yes, I've checked their properties). But when I take the dgQuote.DataBind() statement out, the textboxes and labels appear but the datagrid does not appear (I would think because it has no data in it). My first question is why is this happening?? Is there a setting I'm missing??

 

2. When the statement dgQuote.DataBind() is left in, the datagrid appears filled with data but the datagrid contains columns for every field in the database table. How can I edit which columns to show and which ones not to, I know in my windows apps I could use the DataGridTableStyle but apparently, it is not available in the web app.

 

Appreciate any help anyone can provide.

Posted
When you're formating your datagrid, theres a checkbox that says 'generate columns at runtime'. Uncheck this checkbox and add as much as you want bound columns, give them header names, and specify the their table field

Proudly a Palestinian

Microsoft ASP.NET MVP

My Blog: wessamzeidan.net

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...