p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

aspdotnet_website_programming thread: more than one value in datafield


Message #1 by Greg Partin <GPartin@c...> on Mon, 6 May 2002 10:16:48 -0400
Hi folks,

I was wondering if it is possible to have more than one value in the
datafield for a bound column.  The reason for this is so I can do something
like this:

<asp:BoundColumn HeaderText="Students Taken"
DataField="num_students_taken,class_id" DataFormatString="<a
href=http://localhost/BeginningTests/reports/rpt_ClassProgressReportResults.
aspx?Class={1:g}>{0:g}</a>" runat="server"></asp:BoundColumn>

Notice that I am bringing back two columns and trying to use them in my
dataformatstring with {0:g} and {1:g}

Or is there a better way to do this?

thanks,
Greg
Message #2 by "Minh T. Nguyen" <nguyentriminh@y...> on Tue, 7 May 2002 10:17:26 -0700
Greg,

	I myself have asked the question many times, and so far I have
not received any suggestions. Apparently this can't be done, which I
find very sad, because it's not that hard to code by the .NET
developers.
	Anyhow, what I right now do is in my code-behind I add an extra
column to my DataTable named "URLToDisplay". I then iterate through all
the rows and generate that URLToDisplay column myself and then use that
in the .aspx file. Kinda stupid.

Minh.

-----Original Message-----
From: Greg Partin [mailto:GPartin@c...] 
Sent: Monday, May 06, 2002 7:17 AM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] more than one value in
datafield


Hi folks,

I was wondering if it is possible to have more than one value in the
datafield for a bound column.  The reason for this is so I can do
something
like this:

<asp:BoundColumn HeaderText="Students Taken"
DataField="num_students_taken,class_id" DataFormatString="<a
href=http://localhost/BeginningTests/reports/rpt_ClassProgressReportResu
lts.
aspx?Class={1:g}>{0:g}</a>" runat="server"></asp:BoundColumn>

Notice that I am bringing back two columns and trying to use them in my
dataformatstring with {0:g} and {1:g}

Or is there a better way to do this?

thanks,
Greg


Message #3 by Greg Partin <GPartin@c...> on Tue, 7 May 2002 13:25:57 -0400
Thanks Minh, I will try your suggestion!

Greg

-----Original Message-----
From: Minh T. Nguyen [mailto:nguyentriminh@y...]
Sent: Tuesday, May 07, 2002 1:17 PM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] RE: more than one value in
datafield


Greg,

	I myself have asked the question many times, and so far I have
not received any suggestions. Apparently this can't be done, which I
find very sad, because it's not that hard to code by the .NET
developers.
	Anyhow, what I right now do is in my code-behind I add an extra
column to my DataTable named "URLToDisplay". I then iterate through all
the rows and generate that URLToDisplay column myself and then use that
in the .aspx file. Kinda stupid.

Minh.

-----Original Message-----
From: Greg Partin [mailto:GPartin@c...] 
Sent: Monday, May 06, 2002 7:17 AM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] more than one value in
datafield


Hi folks,

I was wondering if it is possible to have more than one value in the
datafield for a bound column.  The reason for this is so I can do
something
like this:

<asp:BoundColumn HeaderText="Students Taken"
DataField="num_students_taken,class_id" DataFormatString="<a
href=http://localhost/BeginningTests/reports/rpt_ClassProgressReportResu
lts.
aspx?Class={1:g}>{0:g}</a>" runat="server"></asp:BoundColumn>

Notice that I am bringing back two columns and trying to use them in my
dataformatstring with {0:g} and {1:g}

Or is there a better way to do this?

thanks,
Greg




---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002
 
Message #4 by "Lewis Bass" <lewis@t...> on Wed, 8 May 2002 07:09:22 -0600
Have you tried something like this?

<asp:TemplateColumn HeaderText="Customer #" FooterText="Customer #">

<ItemTemplate>

<asp:TextBox id="tbCuid" runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.cuid") %>' Width="75%">

</asp:TextBox>

<asp:button id="btnFindCust" runat="server" Text="Find"
Width="20%"></asp:button>

<asp:TextBox id="tbpct_bil" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.pct_bil") %>' Width="100%">

</asp:TextBox>

</ItemTemplate>

</asp:TemplateColumn>


This renders two textboxes and a button in the same cell of the datagrid,
and it works for me

----- Original Message -----
From: "Minh T. Nguyen" <nguyentriminh@y...>
To: "Website Programming with ASP.NET"
<aspdotnet_website_programming@p...>
Sent: Tuesday, May 07, 2002 11:17 AM
Subject: [aspdotnet_website_programming] RE: more than one value in
datafield


> Greg,
>
> I myself have asked the question many times, and so far I have
> not received any suggestions. Apparently this can't be done, which I
> find very sad, because it's not that hard to code by the .NET
> developers.
> Anyhow, what I right now do is in my code-behind I add an extra
> column to my DataTable named "URLToDisplay". I then iterate through all
> the rows and generate that URLToDisplay column myself and then use that
> in the .aspx file. Kinda stupid.
>
> Minh.
>
> -----Original Message-----
> From: Greg Partin [mailto:GPartin@c...]
> Sent: Monday, May 06, 2002 7:17 AM
> To: Website Programming with ASP.NET
> Subject: [aspdotnet_website_programming] more than one value in
> datafield
>
>
> Hi folks,
>
> I was wondering if it is possible to have more than one value in the
> datafield for a bound column.  The reason for this is so I can do
> something
> like this:
>
> <asp:BoundColumn HeaderText="Students Taken"
> DataField="num_students_taken,class_id" DataFormatString="<a
> href=http://localhost/BeginningTests/reports/rpt_ClassProgressReportResu
> lts.
> aspx?Class={1:g}>{0:g}</a>" runat="server"></asp:BoundColumn>
>
> Notice that I am bringing back two columns and trying to use them in my
> dataformatstring with {0:g} and {1:g}
>
> Or is there a better way to do this?
>
> thanks,
> Greg
>
>
>
>

Message #5 by Greg Partin <GPartin@c...> on Wed, 8 May 2002 09:21:19 -0400
Thank you for all your help.  I will share my code to create a dynamic URL
based on the value from the database.

Here is my code on the HTML side.  Notice that for the NavigateURL I call a
function called checklink where I pass it some values that I brought back
from the database:

<asp:TemplateColumn HeaderText="Students Taken">
	<ItemTemplate>
		<asp:HyperLink ID=taken Runat="server" text='<%#
container.dataitem("num_students_taken") %>' NavigateUrl='<%#
checklink(container.dataitem("num_students_taken"),container.dataitem("test_
title"),container.dataitem("content_standard_description"),container.dataite
m("test_id"), container.dataitem("class_id"),
container.dataitem("grade_cd")) %>'>
		</asp:HyperLink>
	</ItemTemplate>
</asp:TemplateColumn>

In my code behind I have a function called checklink:

Public Function checklink(ByVal hyperlink As Integer, ByVal testtitle As
String, ByVal description As String, ByVal test_id As Integer, ByVal
class_id As Integer, ByVal grade_cd As String) As String

        If hyperlink = 0 Then 'here is where I do my check to see if I want
the link to be clickable
            checklink = Nothing
        Else
            Dim ClassHandle As Control 
Page.FindControl("ClassProgressClassDropDown")
            Dim ClassControl As BeginningTests.ClassDropDown
            Dim SubjectHandle As Control 
Page.FindControl("ClassProgressSubjectDropDown")
            Dim SubjectControl As BeginningTests.SubjectDropDown
            Dim FilterHandle As Control 
Page.FindControl("ClassProgressScoreFilter")
            Dim FilterControl As BeginningTests.ScoreFilter

            SubjectControl = CType(SubjectHandle,
BeginningTests.SubjectDropDown)
            ClassControl = CType(ClassHandle, BeginningTests.ClassDropDown)
            FilterControl = CType(FilterHandle, BeginningTests.ScoreFilter)

            checklink 
"http://localhost/BeginningTests/reports/rpt_ClassProgressReportResults.aspx
?Test_Title=" & testtitle & "&Description=" & description &
"&ReportTitle=Class Progress Report&Filter=" &
FilterControl.ScoreFilter.SelectedItem.Text & "&Class=" &
ClassControl.ClassDropDown.SelectedItem.Text & "&TestID=" & test_id &
"&ClassID=" & class_id & "&GroupName=Tested&SubjectCD=" &
SubjectControl.Subject.SelectedItem.Value & "&GradeCD=" & grade_cd 'here is
where I build the link
        End If

    End Function

Just in case anyone else is trying to do this!

Greg


-----Original Message-----
From: Lewis Bass [mailto:lewis@t...]
Sent: Wednesday, May 08, 2002 9:09 AM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] RE: more than one value in
datafield


Have you tried something like this?

<asp:TemplateColumn HeaderText="Customer #" FooterText="Customer #">

<ItemTemplate>

<asp:TextBox id="tbCuid" runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.cuid") %>' Width="75%">

</asp:TextBox>

<asp:button id="btnFindCust" runat="server" Text="Find"
Width="20%"></asp:button>

<asp:TextBox id="tbpct_bil" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.pct_bil") %>' Width="100%">

</asp:TextBox>

</ItemTemplate>

</asp:TemplateColumn>


This renders two textboxes and a button in the same cell of the datagrid,
and it works for me

----- Original Message -----
From: "Minh T. Nguyen" <nguyentriminh@y...>
To: "Website Programming with ASP.NET"
<aspdotnet_website_programming@p...>
Sent: Tuesday, May 07, 2002 11:17 AM
Subject: [aspdotnet_website_programming] RE: more than one value in
datafield


> Greg,
>
> I myself have asked the question many times, and so far I have
> not received any suggestions. Apparently this can't be done, which I
> find very sad, because it's not that hard to code by the .NET
> developers.
> Anyhow, what I right now do is in my code-behind I add an extra
> column to my DataTable named "URLToDisplay". I then iterate through all
> the rows and generate that URLToDisplay column myself and then use that
> in the .aspx file. Kinda stupid.
>
> Minh.
>
> -----Original Message-----
> From: Greg Partin [mailto:GPartin@c...]
> Sent: Monday, May 06, 2002 7:17 AM
> To: Website Programming with ASP.NET
> Subject: [aspdotnet_website_programming] more than one value in
> datafield
>
>
> Hi folks,
>
> I was wondering if it is possible to have more than one value in the
> datafield for a bound column.  The reason for this is so I can do
> something
> like this:
>
> <asp:BoundColumn HeaderText="Students Taken"
> DataField="num_students_taken,class_id" DataFormatString="<a
> href=http://localhost/BeginningTests/reports/rpt_ClassProgressReportResu
> lts.
> aspx?Class={1:g}>{0:g}</a>" runat="server"></asp:BoundColumn>
>
> Notice that I am bringing back two columns and trying to use them in my
> dataformatstring with {0:g} and {1:g}
>
> Or is there a better way to do this?
>
> thanks,
> Greg
>
>
>
>



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.360 / Virus Database: 199 - Release Date: 5/7/2002
 

  Return to Index