Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Datagrid / Dataset / Relations

Reply
Thread Tools

Datagrid / Dataset / Relations

 
 
Patrick
Guest
Posts: n/a
 
      01-26-2004
Hi , I'm sure that I'm not the first one with that question. I have two
tables (both in the Dataset), where one is

parent_table
id:
sname:

child_table:
id
iparent_id
schildname

now i load into the datatable the child_table as Datamember. So now I can
edit, Insert and delete these Items. now what I want to do is to display
instead of the parent_id the parent_table.sname. How can i do this? and
second step is, when editing that row, that for the parent will be displayed
a dropdown-list... anyone an idea/url to solve these problems?

thanks
patrick


 
Reply With Quote
 
 
 
 
Branimir Giurov
Guest
Posts: n/a
 
      01-26-2004
Hi Patrick,
you can do a Select() on the parent table, while you bind the rows to the
datasource. Your aspx page should look like this:

<aspataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 24px; POSITION:
absolute; TOP: 19px" runat="server">
<Columns>
<asp:TemplateColumn>
<%# getParentValue(DataBinder.Eval(Container.DataItem,
"parent_id").ToString() ) ) %>
</asp:TemplateColumn>
</Columns>
</aspataGrid>

then into the codebehind:

protected string getParentValue(string parentID)
{
DataRow[] result =
datasource.Tables["parent_table"].Select(string.Format("parent_id ='{0}'",
parentID));
if ( result!=null && result.Length > 0 )
return result[0]["sname"].ToString();
return "";
}

good luck
Branimir

--
Branimir Giurov
MCSD.NET, MCDBA
eAgility LLC
"Patrick" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi , I'm sure that I'm not the first one with that question. I have two
> tables (both in the Dataset), where one is
>
> parent_table
> id:
> sname:
>
> child_table:
> id
> iparent_id
> schildname
>
> now i load into the datatable the child_table as Datamember. So now I can
> edit, Insert and delete these Items. now what I want to do is to display
> instead of the the parent_table.sname. How can i do this? and
> second step is, when editing that row, that for the parent will be

displayed
> a dropdown-list... anyone an idea/url to solve these problems?
>
> thanks
> patrick
>
>



 
Reply With Quote
 
 
 
 
Patrick
Guest
Posts: n/a
 
      01-27-2004
Thanks, it works fine with that solution


"Branimir Giurov" <(E-Mail Removed)> schrieb im Newsbeitrag
news:uIM$(E-Mail Removed)...
> Hi Patrick,
> you can do a Select() on the parent table, while you bind the rows to the
> datasource. Your aspx page should look like this:
>
> <aspataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 24px; POSITION:
> absolute; TOP: 19px" runat="server">
> <Columns>
> <asp:TemplateColumn>
> <%# getParentValue(DataBinder.Eval(Container.DataItem,
> "parent_id").ToString() ) ) %>
> </asp:TemplateColumn>
> </Columns>
> </aspataGrid>
>
> then into the codebehind:
>
> protected string getParentValue(string parentID)
> {
> DataRow[] result =
> datasource.Tables["parent_table"].Select(string.Format("parent_id ='{0}'",
> parentID));
> if ( result!=null && result.Length > 0 )
> return result[0]["sname"].ToString();
> return "";
> }
>
> good luck
> Branimir
>
> --
> Branimir Giurov
> MCSD.NET, MCDBA
> eAgility LLC
> "Patrick" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi , I'm sure that I'm not the first one with that question. I have two
> > tables (both in the Dataset), where one is
> >
> > parent_table
> > id:
> > sname:
> >
> > child_table:
> > id
> > iparent_id
> > schildname
> >
> > now i load into the datatable the child_table as Datamember. So now I

can
> > edit, Insert and delete these Items. now what I want to do is to display
> > instead of the the parent_table.sname. How can i do this? and
> > second step is, when editing that row, that for the parent will be

> displayed
> > a dropdown-list... anyone an idea/url to solve these problems?
> >
> > thanks
> > patrick
> >
> >

>
>



 
Reply With Quote
 
Patrick
Guest
Posts: n/a
 
      01-27-2004
Thanks, it works fine with that solution


"Branimir Giurov" <(E-Mail Removed)> schrieb im Newsbeitrag
news:uIM$(E-Mail Removed)...
> Hi Patrick,
> you can do a Select() on the parent table, while you bind the rows to the
> datasource. Your aspx page should look like this:
>
> <aspataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 24px; POSITION:
> absolute; TOP: 19px" runat="server">
> <Columns>
> <asp:TemplateColumn>
> <%# getParentValue(DataBinder.Eval(Container.DataItem,
> "parent_id").ToString() ) ) %>
> </asp:TemplateColumn>
> </Columns>
> </aspataGrid>
>
> then into the codebehind:
>
> protected string getParentValue(string parentID)
> {
> DataRow[] result =
> datasource.Tables["parent_table"].Select(string.Format("parent_id ='{0}'",
> parentID));
> if ( result!=null && result.Length > 0 )
> return result[0]["sname"].ToString();
> return "";
> }
>
> good luck
> Branimir
>
> --
> Branimir Giurov
> MCSD.NET, MCDBA
> eAgility LLC
> "Patrick" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi , I'm sure that I'm not the first one with that question. I have two
> > tables (both in the Dataset), where one is
> >
> > parent_table
> > id:
> > sname:
> >
> > child_table:
> > id
> > iparent_id
> > schildname
> >
> > now i load into the datatable the child_table as Datamember. So now I

can
> > edit, Insert and delete these Items. now what I want to do is to display
> > instead of the the parent_table.sname. How can i do this? and
> > second step is, when editing that row, that for the parent will be

> displayed
> > a dropdown-list... anyone an idea/url to solve these problems?
> >
> > thanks
> > patrick
> >
> >

>
>



 
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
Relations in Dataset MRW ASP .Net 0 12-02-2006 08:34 PM
Dataset relations and nested repeaters? =?Utf-8?B?RGF2ZQ==?= ASP .Net 0 04-15-2006 02:43 AM
Datatable Relations and Datagrid ree32 ASP .Net Datagrid Control 1 12-18-2004 04:13 AM
data relations and datasets inquiry Joe Van Meer ASP .Net 0 05-05-2004 01:30 PM
Can't decide between Relations::Family and Class::DBI Nicolas STAMPF Perl 0 05-04-2004 12:16 PM



Advertisments