Jay1b Posted May 16, 2005 Posted May 16, 2005 I have been programming (to various degree's of success) with VB.NET for quite a while, but i am a complete noobie when it comes to ASP.NET. Initially i created a screen where i can copy the contents of a textbox to a label upon a button click. This was incredibly simple and worked straight away. Now i've tried to move on to using datagrids. I am unable to make the datagrid display, i drag it onto the layout form, press Run and the rest of the form displays perfect, but for some reason the datagrid is just completely invisible as if it wasnt even there. Can someone please tell me what i am doing wrong please? Quote
Administrators PlausiblyDamp Posted May 16, 2005 Administrators Posted May 16, 2005 Are you using the DataGrid with a valid data source? If not then you probably should. If you are then you need to remember to call DataBind on the control to get itself to render. e.g. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim conn As New SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=true") Dim cmd As New SqlCommand("SELECT * FROM Products", conn) Dim ds As New DataSet Dim da As New SqlDataAdapter(cmd) da.Fill(ds) DataGrid1.DataSource = ds DataGrid1.DataBind() End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jay1b Posted May 16, 2005 Author Posted May 16, 2005 Thanks PD. I was missing the DataBind(), I never use it with VB.NET and i swear it works just fine. Only started with ASP today, so there is a few things i need to get use too. Quote
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.