Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Populate label from Datagrid selection

Reply
Thread Tools

Populate label from Datagrid selection

 
 
Euan
Guest
Posts: n/a
 
      04-15-2005
Hi there,

This might be a simple enough question for most of you. But I am pulling
my hair out with this.

I have a datagrid populated from a database. Its a booking form. You
push a button column to select the row. And now I need to give some
specific details from that row in to a label.
Lets say Course Name, Course Date, Trainer, and Location.

I have NO idea how to get those specific details populated in to a
label. How do I select those specific parts from the data reader? I know
the record. And I know I have the info. But I just want the specific parts!

Thanks for your help,
Euan
 
Reply With Quote
 
 
 
 
Elton Wang
Guest
Posts: n/a
 
      04-16-2005
Hi

You can use following steps to do your work.
1) Get all data, including data to be shown in datagrid
(e.g. recordID, description, and others) and detailed data
(e.g. Course Name, Course Date, Trainer, and Location) to
fill into a datatable.

2) Build a datagrid with DataKeyField = "recordID" and few
BoundColumns (for recorded, description, and so on) and a
ButtonColumn.

3) Bind the datagrid with the datatable, and in the mean
time save the datatable in Session.

4) Build ItemCommand event. In the event retrieve clicked
recordID and then pull detailed data from datatable in
Session by following code:

string recordID = datagrid.DataKeys
[e.Item.ItemIndex].ToString();
DataTable data = (DataTable)Session["source"];
DataView dv = data.DefaultView;
dv.RowFilter = "recordID='" + recordID + "'";
DataRowView drv = dv[0];
string CourseName = drv["CourseName"];
string CourseDate = drv["CourseDate"];
string Trainer = drv["Trainer"];
string Location = drv["Location"];

HTH

Elton Wang



>-----Original Message-----
>Hi there,
>
>This might be a simple enough question for most of you.

But I am pulling
>my hair out with this.
>
>I have a datagrid populated from a database. Its a

booking form. You
>push a button column to select the row. And now I need to

give some
>specific details from that row in to a label.
>Lets say Course Name, Course Date, Trainer, and Location.
>
>I have NO idea how to get those specific details

populated in to a
>label. How do I select those specific parts from the data

reader? I know
>the record. And I know I have the info. But I just want

the specific parts!
>
>Thanks for your help,
>Euan
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FormView DropdownList - On Selection Change populate Text Box Satish ASP .Net 8 03-31-2008 03:26 PM
Listbox selection to populate another listbox? Chris Kettenbach ASP .Net 3 06-16-2005 09:19 PM
Populate a popup window with clickable records from an Access DB and upon clicking, populate a selectbox on the original webpage with the clicked record Enjoy Life ASP General 2 02-23-2005 10:48 PM
generate popup for search, then populate parent window with selection Mark ASP .Net 2 02-20-2004 04:59 PM
Populate List Box base on Combo Box Selection Adrian ASP General 1 02-18-2004 09:49 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57