Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > so close..I think

Reply
Thread Tools

so close..I think

 
 
Lerp
Guest
Posts: n/a
 
      05-08-2004
Hi,

I have this sub in which I am trying to get a client name from a second
table based on a clientid value in my datalist. I am having problems
grabbing the clientid value out of my datalist and putting it into my
variable curClientID. How do you grab a value out of a datalist properly
please?

Thx,Lerp



Here's my sub:



'THIS SUB HANDLES GRABBING CLIENT NAMES
Sub dlBookings_OnItemDataBound(sender As Object, e As DataListItemEventArgs)

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then

' Retrieve the Label control in the current DataListItem.
Dim ClientNameLabel As Label =
e.Item.FindControl("clientnamelabel")


'Trying to grab clientid here

********************************************
Dim curClientID
curClientID = e.item.FindControl("clientid")....

********************************************




' GRAB client name using ID from db here
Dim clientlabel As String
Dim strSQL as String


'SQL STATEMENT
strSQL = "SELECT fullname FROM CLIENT WHERE clientid=" & curClientID
'NEW CONNECTION OBJECT
Dim MyConn as New
SQLConnection(ConfigurationSettings.AppSettings("d bConn"))

'NEW DATAREADER
Dim objDR as SQLDataReader

'NEW COMMAND OBJECT
Dim Cmd as New SQLCommand(strSQL, MyConn)

'OPEN CONNECTION
MyConn.Open()

'EXECUTE QUERY AND RETRIEVE DATA INTO READER
objDR = Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)


WHILE objDR.Read
clientlabel = objDR("fullname")
END While

myConn.close

'redisplay it in the DataList.
clientnamelabel.Text = clientlabel

End If



End Sub




 
Reply With Quote
 
 
 
 
jm
Guest
Posts: n/a
 
      05-08-2004

"Lerp" <(E-Mail Removed)> wrote in message
news:%23dwk$(E-Mail Removed)...
> Hi,
>
> I have this sub in which I am trying to get a client name from a second
> table based on a clientid value in my datalist. I am having problems
> grabbing the clientid value out of my datalist and putting it into my
> variable curClientID. How do you grab a value out of a datalist properly
> please?
>
> Thx,Lerp
> Here's my sub:
>
>
>
> 'THIS SUB HANDLES GRABBING CLIENT NAMES
> Sub dlBookings_OnItemDataBound(sender As Object, e As

DataListItemEventArgs)
>
> If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
> ListItemType.AlternatingItem Then
>
> ' Retrieve the Label control in the current DataListItem.
> Dim ClientNameLabel As Label =
> e.Item.FindControl("clientnamelabel")
>
>
> 'Trying to grab clientid here
>
> ********************************************
> Dim curClientID
> curClientID = e.item.FindControl("clientid")....
>
> ********************************************
>
>
>
>
> ' GRAB client name using ID from db here
> Dim clientlabel As String
> Dim strSQL as String
>
>
> 'SQL STATEMENT
> strSQL = "SELECT fullname FROM CLIENT WHERE clientid=" & curClientID
> 'NEW CONNECTION OBJECT
> Dim MyConn as New
> SQLConnection(ConfigurationSettings.AppSettings("d bConn"))
>
> 'NEW DATAREADER
> Dim objDR as SQLDataReader
>
> 'NEW COMMAND OBJECT
> Dim Cmd as New SQLCommand(strSQL, MyConn)
>
> 'OPEN CONNECTION
> MyConn.Open()
>
> 'EXECUTE QUERY AND RETRIEVE DATA INTO READER
> objDR = Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
>
>
> WHILE objDR.Read
> clientlabel = objDR("fullname")
> END While
>
> myConn.close
>
> 'redisplay it in the DataList.
> clientnamelabel.Text = clientlabel
>
> End If
>
>
>
> End Sub


If the curClientID is a label, can't you just get the .text of it? You only
told it to find the control. You did not access any of the properties
associated with it (unless there is something after the elipsis ...).


---

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.677 / Virus Database: 439 - Release Date: 5/4/2004


 
Reply With Quote
 
 
 
 
Lerp
Guest
Posts: n/a
 
      05-08-2004
Hi jm,

I am trying to display the client name on the label in the itemtemplate, but
first I have to read the clientid from the fourth field of the current row
being displayed, do a query based on that clientid, and assign the
clientname value to the label within the datalist loop. My problem is that
I am unsure how to grab the value for the fourth column of the current row
of the datalist loop. there is nothing after the elipsis. I am unsure what
to write in order to grab that column value. I am coming from asp
background into .net.

Cheers, Lerp





"jm" <(E-Mail Removed)> wrote in message
news:BPanc.6774$z06.1276684@attbi_s01...
>
> "Lerp" <(E-Mail Removed)> wrote in message
> news:%23dwk$(E-Mail Removed)...
> > Hi,
> >
> > I have this sub in which I am trying to get a client name from a second
> > table based on a clientid value in my datalist. I am having problems
> > grabbing the clientid value out of my datalist and putting it into my
> > variable curClientID. How do you grab a value out of a datalist

properly
> > please?
> >
> > Thx,Lerp
> > Here's my sub:
> >
> >
> >
> > 'THIS SUB HANDLES GRABBING CLIENT NAMES
> > Sub dlBookings_OnItemDataBound(sender As Object, e As

> DataListItemEventArgs)
> >
> > If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
> > ListItemType.AlternatingItem Then
> >
> > ' Retrieve the Label control in the current DataListItem.
> > Dim ClientNameLabel As Label =
> > e.Item.FindControl("clientnamelabel")
> >
> >
> > 'Trying to grab clientid here
> >
> > ********************************************
> > Dim curClientID
> > curClientID = e.item.FindControl("clientid")....
> >
> > ********************************************
> >
> >
> >
> >
> > ' GRAB client name using ID from db here
> > Dim clientlabel As String
> > Dim strSQL as String
> >
> >
> > 'SQL STATEMENT
> > strSQL = "SELECT fullname FROM CLIENT WHERE clientid=" & curClientID
> > 'NEW CONNECTION OBJECT
> > Dim MyConn as New
> > SQLConnection(ConfigurationSettings.AppSettings("d bConn"))
> >
> > 'NEW DATAREADER
> > Dim objDR as SQLDataReader
> >
> > 'NEW COMMAND OBJECT
> > Dim Cmd as New SQLCommand(strSQL, MyConn)
> >
> > 'OPEN CONNECTION
> > MyConn.Open()
> >
> > 'EXECUTE QUERY AND RETRIEVE DATA INTO READER
> > objDR =

Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
> >
> >
> > WHILE objDR.Read
> > clientlabel = objDR("fullname")
> > END While
> >
> > myConn.close
> >
> > 'redisplay it in the DataList.
> > clientnamelabel.Text = clientlabel
> >
> > End If
> >
> >
> >
> > End Sub

>
> If the curClientID is a label, can't you just get the .text of it? You

only
> told it to find the control. You did not access any of the properties
> associated with it (unless there is something after the elipsis ...).
>
>
> ---
>
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.677 / Virus Database: 439 - Release Date: 5/4/2004
>
>



 
Reply With Quote
 
jm
Guest
Posts: n/a
 
      05-09-2004

"Lerp" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi jm,
>
> I am trying to display the client name on the label in the itemtemplate,

but
> first I have to read the clientid from the fourth field of the current row
> being displayed, do a query based on that clientid, and assign the
> clientname value to the label within the datalist loop. My problem is

that
> I am unsure how to grab the value for the fourth column of the current row
> of the datalist loop. there is nothing after the elipsis. I am unsure

what
> to write in order to grab that column value. I am coming from asp
> background into .net.
>
> Cheers, Lerp
>
>
>
>
>
> "jm" <(E-Mail Removed)> wrote in message
> news:BPanc.6774$z06.1276684@attbi_s01...
> >
> > "Lerp" <(E-Mail Removed)> wrote in message
> > news:%23dwk$(E-Mail Removed)...
> > > Hi,
> > >
> > > I have this sub in which I am trying to get a client name from a

second
> > > table based on a clientid value in my datalist. I am having problems
> > > grabbing the clientid value out of my datalist and putting it into my
> > > variable curClientID. How do you grab a value out of a datalist

> properly
> > > please?
> > >
> > > Thx,Lerp
> > > Here's my sub:
> > >
> > >
> > >
> > > 'THIS SUB HANDLES GRABBING CLIENT NAMES
> > > Sub dlBookings_OnItemDataBound(sender As Object, e As

> > DataListItemEventArgs)
> > >
> > > If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
> > > ListItemType.AlternatingItem Then
> > >
> > > ' Retrieve the Label control in the current DataListItem.
> > > Dim ClientNameLabel As Label =
> > > e.Item.FindControl("clientnamelabel")
> > >
> > >
> > > 'Trying to grab clientid here
> > >
> > > ********************************************
> > > Dim curClientID
> > > curClientID = e.item.FindControl("clientid")....
> > >
> > > ********************************************
> > >
> > >
> > >
> > >
> > > ' GRAB client name using ID from db here
> > > Dim clientlabel As String
> > > Dim strSQL as String
> > >
> > >
> > > 'SQL STATEMENT
> > > strSQL = "SELECT fullname FROM CLIENT WHERE clientid=" &

curClientID
> > > 'NEW CONNECTION OBJECT
> > > Dim MyConn as New
> > > SQLConnection(ConfigurationSettings.AppSettings("d bConn"))
> > >
> > > 'NEW DATAREADER
> > > Dim objDR as SQLDataReader
> > >
> > > 'NEW COMMAND OBJECT
> > > Dim Cmd as New SQLCommand(strSQL, MyConn)
> > >
> > > 'OPEN CONNECTION
> > > MyConn.Open()
> > >
> > > 'EXECUTE QUERY AND RETRIEVE DATA INTO READER
> > > objDR =

> Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
> > >
> > >
> > > WHILE objDR.Read
> > > clientlabel = objDR("fullname")
> > > END While
> > >
> > > myConn.close
> > >
> > > 'redisplay it in the DataList.
> > > clientnamelabel.Text = clientlabel
> > >
> > > End If
> > >
> > >
> > >
> > > End Sub

> >
> > If the curClientID is a label, can't you just get the .text of it? You

> only
> > told it to find the control. You did not access any of the properties
> > associated with it (unless there is something after the elipsis ...).
> >
> >
> > ---
> >
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.677 / Virus Database: 439 - Release Date: 5/4/2004
> >

Okay, first, just to let you know "ClientID" is a reserved word in .net for
getting the unique asp.net generated value for a given control; especially
useful in building javascript applications. It allows you to use the
objects on the client that asp.net generates a unique number for (like the
ctl1, etc. do a view source for an example.)

I believe you are using ClientID like OrderID and it looks like you want to
retrieve a value from a datalist that you generate (and is visible) and then
use that value for use in another query that those values are then sent to
the user.

Say you have a datagrid:

sub mysub(sender as Object, e as DataGridItemEventArgs)

CType(e.Items.Cells(0).Controls(0), Button).visible = false

so, in:

"Dim curClientID
> > > curClientID = e.item.FindControl("clientid")...."


put:

Dim curClientID as String = e.Items.Cells(?).Controls(?).label).text

to retrieve the value at that location. Use the type of control you have
and its associated methods and properties (like .text).

Look here for a great primer (I know you may not be using the datagrid, but
it will still help you.):

http://aspnet.4guysfromrolla.com/art...71002-1.3.aspx

in here you will see an example close to what I have shown you. However,
you should go to the first part of the set of articles and start over:
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

However, it looks like to get your data for your first datalist that you are
sending to the client you have some SQL or data somewhere you are retrieving
to build the datalist in the first place. So, instead of printing out the
datalist first and then searching for the newly printed out value from your
new datalist, just get the value from the retrieved SQL results, save it a
variable and then use THAT value for your next query.

For example, assume that I just queried a database and retreived my results.
You could get a value at the proper point in your retrieval by:

dim curClientID as string =
datasource.tables(0).rows(0)("client_id").toString ()

Then, use curClientID below in your next set of code.

I hope I understood your problem and that this somehow helps you (also, you
may also wish to avoid top posting for reading clarity.)

For a view of what I was saying about ClientID, see:


http://msdn.microsoft.com/library/de...entIDTopic.asp

"Lerp" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi jm,
>
> I am trying to display the client name on the label in the itemtemplate,

but
> first I have to read the clientid from the fourth field of the current row
> being displayed, do a query based on that clientid, and assign the
> clientname value to the label within the datalist loop. My problem is

that
> I am unsure how to grab the value for the fourth column of the current row
> of the datalist loop. there is nothing after the elipsis. I am unsure

what
> to write in order to grab that column value. I am coming from asp
> background into .net.
>
> Cheers, Lerp
>
>
>
>
>
> "jm" <(E-Mail Removed)> wrote in message
> news:BPanc.6774$z06.1276684@attbi_s01...
> >
> > "Lerp" <(E-Mail Removed)> wrote in message
> > news:%23dwk$(E-Mail Removed)...
> > > Hi,
> > >
> > > I have this sub in which I am trying to get a client name from a

second
> > > table based on a clientid value in my datalist. I am having problems
> > > grabbing the clientid value out of my datalist and putting it into my
> > > variable curClientID. How do you grab a value out of a datalist

> properly
> > > please?
> > >
> > > Thx,Lerp
> > > Here's my sub:
> > >
> > >
> > >
> > > 'THIS SUB HANDLES GRABBING CLIENT NAMES
> > > Sub dlBookings_OnItemDataBound(sender As Object, e As

> > DataListItemEventArgs)
> > >
> > > If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
> > > ListItemType.AlternatingItem Then
> > >
> > > ' Retrieve the Label control in the current DataListItem.
> > > Dim ClientNameLabel As Label =
> > > e.Item.FindControl("clientnamelabel")
> > >
> > >
> > > 'Trying to grab clientid here
> > >
> > > ********************************************
> > > Dim curClientID
> > > curClientID = e.item.FindControl("clientid")....
> > >
> > > ********************************************
> > >
> > >
> > >
> > >
> > > ' GRAB client name using ID from db here
> > > Dim clientlabel As String
> > > Dim strSQL as String
> > >
> > >
> > > 'SQL STATEMENT
> > > strSQL = "SELECT fullname FROM CLIENT WHERE clientid=" &

curClientID
> > > 'NEW CONNECTION OBJECT
> > > Dim MyConn as New
> > > SQLConnection(ConfigurationSettings.AppSettings("d bConn"))
> > >
> > > 'NEW DATAREADER
> > > Dim objDR as SQLDataReader
> > >
> > > 'NEW COMMAND OBJECT
> > > Dim Cmd as New SQLCommand(strSQL, MyConn)
> > >
> > > 'OPEN CONNECTION
> > > MyConn.Open()
> > >
> > > 'EXECUTE QUERY AND RETRIEVE DATA INTO READER
> > > objDR =

> Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
> > >
> > >
> > > WHILE objDR.Read
> > > clientlabel = objDR("fullname")
> > > END While
> > >
> > > myConn.close
> > >
> > > 'redisplay it in the DataList.
> > > clientnamelabel.Text = clientlabel
> > >
> > > End If
> > >
> > >
> > >
> > > End Sub

> >
> > If the curClientID is a label, can't you just get the .text of it? You

> only
> > told it to find the control. You did not access any of the properties
> > associated with it (unless there is something after the elipsis ...).
> >
> >
> > ---
> >
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.677 / Virus Database: 439 - Release Date: 5/4/2004
> >

Okay, first, just to let you know "ClientID" is a reserved word in .net for
getting the unique asp.net generated value for a given control; especially
useful in building javascript applications. It allows you to use the
objects on the client that asp.net generates a unique number for (like the
ctl1, etc. do a view source for an example.)

I believe you are using ClientID like OrderID and it looks like you want to
retrieve a value from a datalist that you generate (and is visible) and then
use that value for use in another query that those values are then sent to
the user.

Say you have a datagrid:

sub mysub(sender as Object, e as DataGridItemEventArgs)

CType(e.Items.Cells(0).Controls(0), Button).visible = false

so, in:

"Dim curClientID
> > > curClientID = e.item.FindControl("clientid")...."


put:

Dim curClientID as String = e.Items.Cells(?).Controls(?).label).text

to retrieve the value at that location. Use the type of control you have
and its associated methods and properties (like .text).

Look here for a great primer (I know you may not be using the datagrid, but
it will still help you.):

http://aspnet.4guysfromrolla.com/art...71002-1.3.aspx

in here you will see an example close to what I have shown you. However,
you should go to the first part of the set of articles and start over:
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

However, it looks like to get your data for your first datalist that you are
sending to the client you have some SQL or data somewhere you are retrieving
to build the datalist in the first place. So, instead of printing out the
datalist first and then searching for the newly printed out value from your
new datalist, just get the value from the retrieved SQL results, save it a
variable and then use THAT value for your next query.

For example, assume that I just queried a database and retreived my results.
You could get a value at the proper point in your retrieval by:

dim curClientID as string =
datasource.tables(0).rows(0)("client_id").toString ()

Then, use curClientID below in your next set of code.

I hope I understood your problem and that this somehow helps you (also, you
may also wish to avoid top posting for reading clarity.)

For a view of what I was saying about ClientID, see:


http://msdn.microsoft.com/library/de...entIDTopic.asp


 
Reply With Quote
 
Lerp
Guest
Posts: n/a
 
      05-09-2004
Thank you jm, I managed to get the name to display properly based on most
of your suggestions. Thank you again.

Thx, Lerp


"jm" <(E-Mail Removed)> wrote in message
news:_%fnc.7930$536.1607804@attbi_s03...
>
> "Lerp" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi jm,
> >
> > I am trying to display the client name on the label in the itemtemplate,

> but
> > first I have to read the clientid from the fourth field of the current

row
> > being displayed, do a query based on that clientid, and assign the
> > clientname value to the label within the datalist loop. My problem is

> that
> > I am unsure how to grab the value for the fourth column of the current

row
> > of the datalist loop. there is nothing after the elipsis. I am unsure

> what
> > to write in order to grab that column value. I am coming from asp
> > background into .net.
> >
> > Cheers, Lerp
> >
> >
> >
> >
> >
> > "jm" <(E-Mail Removed)> wrote in message
> > news:BPanc.6774$z06.1276684@attbi_s01...
> > >
> > > "Lerp" <(E-Mail Removed)> wrote in message
> > > news:%23dwk$(E-Mail Removed)...
> > > > Hi,
> > > >
> > > > I have this sub in which I am trying to get a client name from a

> second
> > > > table based on a clientid value in my datalist. I am having

problems
> > > > grabbing the clientid value out of my datalist and putting it into

my
> > > > variable curClientID. How do you grab a value out of a datalist

> > properly
> > > > please?
> > > >
> > > > Thx,Lerp
> > > > Here's my sub:
> > > >
> > > >
> > > >
> > > > 'THIS SUB HANDLES GRABBING CLIENT NAMES
> > > > Sub dlBookings_OnItemDataBound(sender As Object, e As
> > > DataListItemEventArgs)
> > > >
> > > > If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
> > > > ListItemType.AlternatingItem Then
> > > >
> > > > ' Retrieve the Label control in the current DataListItem.
> > > > Dim ClientNameLabel As Label =
> > > > e.Item.FindControl("clientnamelabel")
> > > >
> > > >
> > > > 'Trying to grab clientid here
> > > >
> > > > ********************************************
> > > > Dim curClientID
> > > > curClientID = e.item.FindControl("clientid")....
> > > >
> > > > ********************************************
> > > >
> > > >
> > > >
> > > >
> > > > ' GRAB client name using ID from db here
> > > > Dim clientlabel As String
> > > > Dim strSQL as String
> > > >
> > > >
> > > > 'SQL STATEMENT
> > > > strSQL = "SELECT fullname FROM CLIENT WHERE clientid=" &

> curClientID
> > > > 'NEW CONNECTION OBJECT
> > > > Dim MyConn as New
> > > > SQLConnection(ConfigurationSettings.AppSettings("d bConn"))
> > > >
> > > > 'NEW DATAREADER
> > > > Dim objDR as SQLDataReader
> > > >
> > > > 'NEW COMMAND OBJECT
> > > > Dim Cmd as New SQLCommand(strSQL, MyConn)
> > > >
> > > > 'OPEN CONNECTION
> > > > MyConn.Open()
> > > >
> > > > 'EXECUTE QUERY AND RETRIEVE DATA INTO READER
> > > > objDR =

> > Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
> > > >
> > > >
> > > > WHILE objDR.Read
> > > > clientlabel = objDR("fullname")
> > > > END While
> > > >
> > > > myConn.close
> > > >
> > > > 'redisplay it in the DataList.
> > > > clientnamelabel.Text = clientlabel
> > > >
> > > > End If
> > > >
> > > >
> > > >
> > > > End Sub
> > >
> > > If the curClientID is a label, can't you just get the .text of it?

You
> > only
> > > told it to find the control. You did not access any of the properties
> > > associated with it (unless there is something after the elipsis ...).
> > >
> > >
> > > ---
> > >
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.677 / Virus Database: 439 - Release Date: 5/4/2004
> > >

> Okay, first, just to let you know "ClientID" is a reserved word in .net

for
> getting the unique asp.net generated value for a given control; especially
> useful in building javascript applications. It allows you to use the
> objects on the client that asp.net generates a unique number for (like the
> ctl1, etc. do a view source for an example.)
>
> I believe you are using ClientID like OrderID and it looks like you want

to
> retrieve a value from a datalist that you generate (and is visible) and

then
> use that value for use in another query that those values are then sent to
> the user.
>
> Say you have a datagrid:
>
> sub mysub(sender as Object, e as DataGridItemEventArgs)
>
> CType(e.Items.Cells(0).Controls(0), Button).visible = false
>
> so, in:
>
> "Dim curClientID
> > > > curClientID = e.item.FindControl("clientid")...."

>
> put:
>
> Dim curClientID as String = e.Items.Cells(?).Controls(?).label).text
>
> to retrieve the value at that location. Use the type of control you have
> and its associated methods and properties (like .text).
>
> Look here for a great primer (I know you may not be using the datagrid,

but
> it will still help you.):
>
> http://aspnet.4guysfromrolla.com/art...71002-1.3.aspx
>
> in here you will see an example close to what I have shown you. However,
> you should go to the first part of the set of articles and start over:
> http://aspnet.4guysfromrolla.com/articles/040502-1.aspx
>
> However, it looks like to get your data for your first datalist that you

are
> sending to the client you have some SQL or data somewhere you are

retrieving
> to build the datalist in the first place. So, instead of printing out the
> datalist first and then searching for the newly printed out value from

your
> new datalist, just get the value from the retrieved SQL results, save it a
> variable and then use THAT value for your next query.
>
> For example, assume that I just queried a database and retreived my

results.
> You could get a value at the proper point in your retrieval by:
>
> dim curClientID as string =
> datasource.tables(0).rows(0)("client_id").toString ()
>
> Then, use curClientID below in your next set of code.
>
> I hope I understood your problem and that this somehow helps you (also,

you
> may also wish to avoid top posting for reading clarity.)
>
> For a view of what I was saying about ClientID, see:
>
>
>

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemWebUIControlClassClientIDTopic.asp
>
> "Lerp" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi jm,
> >
> > I am trying to display the client name on the label in the itemtemplate,

> but
> > first I have to read the clientid from the fourth field of the current

row
> > being displayed, do a query based on that clientid, and assign the
> > clientname value to the label within the datalist loop. My problem is

> that
> > I am unsure how to grab the value for the fourth column of the current

row
> > of the datalist loop. there is nothing after the elipsis. I am unsure

> what
> > to write in order to grab that column value. I am coming from asp
> > background into .net.
> >
> > Cheers, Lerp
> >
> >
> >
> >
> >
> > "jm" <(E-Mail Removed)> wrote in message
> > news:BPanc.6774$z06.1276684@attbi_s01...
> > >
> > > "Lerp" <(E-Mail Removed)> wrote in message
> > > news:%23dwk$(E-Mail Removed)...
> > > > Hi,
> > > >
> > > > I have this sub in which I am trying to get a client name from a

> second
> > > > table based on a clientid value in my datalist. I am having

problems
> > > > grabbing the clientid value out of my datalist and putting it into

my
> > > > variable curClientID. How do you grab a value out of a datalist

> > properly
> > > > please?
> > > >
> > > > Thx,Lerp
> > > > Here's my sub:
> > > >
> > > >
> > > >
> > > > 'THIS SUB HANDLES GRABBING CLIENT NAMES
> > > > Sub dlBookings_OnItemDataBound(sender As Object, e As
> > > DataListItemEventArgs)
> > > >
> > > > If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
> > > > ListItemType.AlternatingItem Then
> > > >
> > > > ' Retrieve the Label control in the current DataListItem.
> > > > Dim ClientNameLabel As Label =
> > > > e.Item.FindControl("clientnamelabel")
> > > >
> > > >
> > > > 'Trying to grab clientid here
> > > >
> > > > ********************************************
> > > > Dim curClientID
> > > > curClientID = e.item.FindControl("clientid")....
> > > >
> > > > ********************************************
> > > >
> > > >
> > > >
> > > >
> > > > ' GRAB client name using ID from db here
> > > > Dim clientlabel As String
> > > > Dim strSQL as String
> > > >
> > > >
> > > > 'SQL STATEMENT
> > > > strSQL = "SELECT fullname FROM CLIENT WHERE clientid=" &

> curClientID
> > > > 'NEW CONNECTION OBJECT
> > > > Dim MyConn as New
> > > > SQLConnection(ConfigurationSettings.AppSettings("d bConn"))
> > > >
> > > > 'NEW DATAREADER
> > > > Dim objDR as SQLDataReader
> > > >
> > > > 'NEW COMMAND OBJECT
> > > > Dim Cmd as New SQLCommand(strSQL, MyConn)
> > > >
> > > > 'OPEN CONNECTION
> > > > MyConn.Open()
> > > >
> > > > 'EXECUTE QUERY AND RETRIEVE DATA INTO READER
> > > > objDR =

> > Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
> > > >
> > > >
> > > > WHILE objDR.Read
> > > > clientlabel = objDR("fullname")
> > > > END While
> > > >
> > > > myConn.close
> > > >
> > > > 'redisplay it in the DataList.
> > > > clientnamelabel.Text = clientlabel
> > > >
> > > > End If
> > > >
> > > >
> > > >
> > > > End Sub
> > >
> > > If the curClientID is a label, can't you just get the .text of it?

You
> > only
> > > told it to find the control. You did not access any of the properties
> > > associated with it (unless there is something after the elipsis ...).
> > >
> > >
> > > ---
> > >
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.677 / Virus Database: 439 - Release Date: 5/4/2004
> > >

> Okay, first, just to let you know "ClientID" is a reserved word in .net

for
> getting the unique asp.net generated value for a given control; especially
> useful in building javascript applications. It allows you to use the
> objects on the client that asp.net generates a unique number for (like the
> ctl1, etc. do a view source for an example.)
>
> I believe you are using ClientID like OrderID and it looks like you want

to
> retrieve a value from a datalist that you generate (and is visible) and

then
> use that value for use in another query that those values are then sent to
> the user.
>
> Say you have a datagrid:
>
> sub mysub(sender as Object, e as DataGridItemEventArgs)
>
> CType(e.Items.Cells(0).Controls(0), Button).visible = false
>
> so, in:
>
> "Dim curClientID
> > > > curClientID = e.item.FindControl("clientid")...."

>
> put:
>
> Dim curClientID as String = e.Items.Cells(?).Controls(?).label).text
>
> to retrieve the value at that location. Use the type of control you have
> and its associated methods and properties (like .text).
>
> Look here for a great primer (I know you may not be using the datagrid,

but
> it will still help you.):
>
> http://aspnet.4guysfromrolla.com/art...71002-1.3.aspx
>
> in here you will see an example close to what I have shown you. However,
> you should go to the first part of the set of articles and start over:
> http://aspnet.4guysfromrolla.com/articles/040502-1.aspx
>
> However, it looks like to get your data for your first datalist that you

are
> sending to the client you have some SQL or data somewhere you are

retrieving
> to build the datalist in the first place. So, instead of printing out the
> datalist first and then searching for the newly printed out value from

your
> new datalist, just get the value from the retrieved SQL results, save it a
> variable and then use THAT value for your next query.
>
> For example, assume that I just queried a database and retreived my

results.
> You could get a value at the proper point in your retrieval by:
>
> dim curClientID as string =
> datasource.tables(0).rows(0)("client_id").toString ()
>
> Then, use curClientID below in your next set of code.
>
> I hope I understood your problem and that this somehow helps you (also,

you
> may also wish to avoid top posting for reading clarity.)
>
> For a view of what I was saying about ClientID, see:
>
>
>

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemWebUIControlClassClientIDTopic.asp
>
>



 
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
I think I will get this and I think I will get that =?iso-8859-1?Q?mark=5Fdigital=A9?= Digital Photography 19 03-18-2006 01:42 AM
Need help: Is Quick-Union-Find the right solution to this problem (Now I don't think so and I think that topological sorting should be the way to go...?) ? aredo3604gif@yahoo.com C Programming 1 04-13-2005 12:48 AM
Need help: Is Quick-Union-Find the right solution to this problem (Now I don't think so and I think that topological sorting should be the way to go...?) ? aredo3604gif@yahoo.com C Programming 0 04-12-2005 05:06 PM
Think your Wireless Network is Secure? Think Again. Careers Computer Security 7 01-31-2004 07:04 AM
Think Off Brand Inks Are Just as Good in your Inkjet Printer - Think Again! John Horner Digital Photography 5 11-09-2003 09:38 PM



Advertisments