jccorner Posted April 12, 2004 Posted April 12, 2004 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. Quote Applying computer technology is simply finding the right wrench to pound in the correct screw
eramgarden Posted April 12, 2004 Posted April 12, 2004 I used this site to do my first datagrid: http://aspnet.4guysfromrolla.com/articles/040502-1.aspx Quote
jccorner Posted April 12, 2004 Author Posted April 12, 2004 eramgarden, thanks, but that doesn't help me. Also, I have fixed the first issue with the textboxes and labels, how can I set the columns of the datagrid. Quote Applying computer technology is simply finding the right wrench to pound in the correct screw
eramgarden Posted April 12, 2004 Posted April 12, 2004 I think that's because u have "select * from .." Specify the columns u want to be displayed instead of doing a select *. Quote
wessamzeidan Posted April 12, 2004 Posted April 12, 2004 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 Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.