Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2004, 11:54 PM
Authorized User
 
Join Date: Jun 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to gadhiav Send a message via Yahoo to gadhiav
Default Questions Regarding Data Grid

Hi frnds,
I am developing a webform using vb.net and my back end is sql 2000.
Now i am trying to fetch data from the back end and display it in the datagrid.
My question is , that when say we have 50 entries in the backend or in the table in the data base, by using the Data Bind method we can eaisly bind the data to the coloumn in the datagrid. Now say with the data that is displayed in the datagrid i want to also metion a cloumn as serial number in the datagrid. Thus the datagrid will look similar to this-:

             Sr. No | Name | Address

I wud like to know how do i insert the Sr no coloumn and how do i get the serial numbers in the datagrid.
If anyone having a idea about this pl come forward and contribute.

My second question is say there is a datagrid of the from
                Sr No. | Training_Name | Course Content
Now here there may not be course content available for all the training_Name specified in the table in the back end. And the Course Content Coloumn is a Hyperlink Coloumn and on the click of, a particular course the contents should appear in the new window...(Just explanantion). My query is How do i
   1. Have Links Displayed For the course contents that are available in my back end for the particular training in the coloumn corresponding to the training name
   2. How can i do it using the datagrid or do i have to use some oher technique to do it.

Life is not the Triumph but the Struggle
__________________
Life is not the Triumph but the Struggle
 
Old July 5th, 2004, 08:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

To add a column to a data grid that isn't in the data source, you can append the column to the data source, or by using a template column that has a label in the field, use the ItemDataBound or ItemCreated events and find that label by:

e.Item.Cells(<index>).FindControl("<id>")

Then assign the label the value.

Not sure what you want for the second half of your question...

Brian
 
Old July 5th, 2004, 04:24 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

to add serial to datagrid just add template column then add this codeto the event Grid_databound:

for examble if the serial column is in 0 location

        If e.Item.ItemIndex <> -1 Then
            e.Item.Cells(0).Text = e.Item.ItemIndex
        End If

Ahmed Ali
Software Developer
 
Old July 5th, 2004, 09:44 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

In the hyperlink column, specify your DataNavigateUrlFormatString attriute to be something like this:

javascript:window.open('detailpage.aspx?courseid={ 0}');

Then your DataNavigateUrlField attribute will be the id field for the course or whatever you have to identify the course. Then you'll need to actually create detailpage.aspx which will show the details of the course based on the link.
 
Old July 8th, 2004, 06:45 AM
Authorized User
 
Join Date: Jun 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to gadhiav Send a message via Yahoo to gadhiav
Default

hi Dude 2000,
I am unbale to use the technique u specified, can u pl be a little more elaborate in what u wanted to metion to me.
Pl waiting for ur reply asap.
Cheers

Life is not the Triumph but the Struggle
 
Old July 11th, 2004, 04:20 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

what is not clear ... just add template column and fill it when binding data to the grid "Grid databound event"....
if you add the serial column to any location for example
add this code
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound

        dim SerialColumnLocation as integer=0

        If e.Item.ItemIndex <> -1 Then
            e.Item.Cells(SerialColumnLocation).Text = e.Item.ItemIndex
        End If
End Sub
waiting.....


Ahmed Ali
Software Developer
 
Old July 12th, 2004, 01:44 AM
Authorized User
 
Join Date: Jun 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to gadhiav Send a message via Yahoo to gadhiav
Default

Hi 2000,
that works great, thanks for all ur help and time.
Hope to have a good communications like this every time .
Thanks So much Once Again,
Cheer
Vishal

Life is not the Triumph but the Struggle





Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Grid how Nuwang .NET Framework 2.0 2 May 12th, 2008 09:23 AM
How to sort data in a data grid? zaheerabbas.sk ASP.NET 1.0 and 1.1 Basics 3 April 10th, 2007 02:37 PM
Export data from data grid to excel pomoc VB.NET 2002/2003 Basics 0 December 16th, 2005 03:11 PM
Export data from data grid to Excel pomoc Visual Basic 2005 Basics 0 December 16th, 2005 02:56 PM
trying to load db data into data grid itsajourney Beginning VB 6 2 June 7th, 2005 12:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.