Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Get Data from one Grid to another

Reply
Thread Tools

Get Data from one Grid to another

 
 
Karl Napp
Guest
Posts: n/a
 
      10-31-2003
I have two tables:
The first is "house" with the columns "house_id" and "house_name".
The second is "room" with "house_id", "room_id", "room_name".

Now, I have two DataGrids. The first should only show the "house_name" and
OnClick it should be able to send the "house_id" to a method that will fill
the second DataGrid.

I have tried <asp:buttoncolumn datatextfield="house_name"> to show the name
but I am not able to retrieve the id to send it to my method


Any help appreciated,
KN



 
Reply With Quote
 
 
 
 
Jos
Guest
Posts: n/a
 
      11-01-2003
Karl Napp wrote:
> I have two tables:
> The first is "house" with the columns "house_id" and "house_name".
> The second is "room" with "house_id", "room_id", "room_name".
>
> Now, I have two DataGrids. The first should only show the
> "house_name" and OnClick it should be able to send the "house_id" to
> a method that will fill the second DataGrid.
>
> I have tried <asp:buttoncolumn datatextfield="house_name"> to show
> the name but I am not able to retrieve the id to send it to my method
>


Set DataKeyField="house_id" for the first datagrid.

Set the CommandName="Select" for your buttoncolumn.

In the OnSelectedIndexChanged event of the first datagrid
(NOT the OnClick event of the button), use this expression to
retrieve the house_id:

selectedHouseID = DataGrid1.DataKeys(e.Item.ItemIndex)

With this ID, bind your second datagrid.

You can also find a complete template in Web Matrix (use the Master/Detail
Data template).

--

Jos


 
Reply With Quote
 
 
 
 
Karl Napp
Guest
Posts: n/a
 
      11-03-2003
> selectedHouseID = DataGrid1.DataKeys(e.Item.ItemIndex)

I do get a compiler error when trying to access
"e.Item"

This seems to be due to the follwing wire-up:

this.Houses.SelectedIndexChanged += new
System.EventHandler(this.Houses_SelectedIndexChang ed);

But when I cange it to

this.Houses.SelectedIndexChanged += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Houses_SelectedIn
dexChanged);

This doesn't help any further...

> You can also find a complete template in Web Matrix (use the Master/Detail
> Data template).


Is it possible to download this for VS.Net, too?


Thank you
KN


 
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
get selected data from dropdownlist in data grid munther ASP .Net 2 09-12-2007 11:26 AM
Passing grid data from one page to another Vasantha peddireddy ASP .Net Datagrid Control 1 08-23-2005 06:01 PM
Passing grid data from one page to another =?Utf-8?B?VmFzYW50aGEgcGVkZGlyZWRkeQ==?= ASP .Net 4 08-23-2005 09:26 AM
Using One XSLT and multiple XML Problem (One is XML and another one is XBRL) loveNUNO XML 2 11-20-2003 06:47 AM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



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