Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Assign Text to Footer Label

Reply
Thread Tools

Assign Text to Footer Label

 
 
Will Chamberlain
Guest
Posts: n/a
 
      10-03-2005
I'm trying to populate a label that is located in the Footer Template of
my DataGrid. I want this to be displayed in a label instead of a
textbox when the user wants to add a new record because I don't want
them to have mess with this field.

-----
Dim ds as new dataset
Dim objCommand as new oledbCommand(strSQL, objConn)
Dim myCommand as new OleDbDataAdapter(strSQL, objConn)

myCommand.Fill(ds, "DataTable")
lblID.text = ds.Tables("DataTable").Rows(0)("ID")
-----

When I run the page nothing is displayed in the footer for this field.
I figured this way would work simply because the datagrid's datasource
is the same dataset. Since the dataset is already filled I should just
be able to grab the ID from the dataset right? Any suggestions?


---
"Our enemies are innovative and resourceful, and so are we. They never
stop thinking of ways to harm our country and our people, and neither do
we." President George W. Bush

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q3VydF9DIFtNVlBd?=
Guest
Posts: n/a
 
      10-03-2005
this is fine, more then likely though you are setting the label text from
outside the proper event. Is the DS already populated? if so you will have to
dig into the DG and grab the footer to get at the label... the label probably
isn't exposed to the page directly.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



"Will Chamberlain" wrote:

> I'm trying to populate a label that is located in the Footer Template of
> my DataGrid. I want this to be displayed in a label instead of a
> textbox when the user wants to add a new record because I don't want
> them to have mess with this field.
>
> -----
> Dim ds as new dataset
> Dim objCommand as new oledbCommand(strSQL, objConn)
> Dim myCommand as new OleDbDataAdapter(strSQL, objConn)
>
> myCommand.Fill(ds, "DataTable")
> lblID.text = ds.Tables("DataTable").Rows(0)("ID")
> -----
>
> When I run the page nothing is displayed in the footer for this field.
> I figured this way would work simply because the datagrid's datasource
> is the same dataset. Since the dataset is already filled I should just
> be able to grab the ID from the dataset right? Any suggestions?
>
>
> ---
> "Our enemies are innovative and resourceful, and so are we. They never
> stop thinking of ways to harm our country and our people, and neither do
> we." President George W. Bush
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
Reply With Quote
 
 
 
 
Trevor Benedict R
Guest
Posts: n/a
 
      10-03-2005
Check out the ItemDataBound Event.

if e.Item.ItemType = ListItemType.Footer Then
'Declare strValue & store the value from
'ds.Tables("DataTable").Rows(0)("ID") into this variable
ctype(e.Item.FindControl(""), Label).Text = strValue
'ds.Tables("DataTable").Rows(0)("ID")
End If

Basically you need to understand the lifetime of each control and then you
will understand as to where you could sneak the code. Hope that helps.

Regards,

Trevor Benedict R
MCSD

"Will Chamberlain" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to populate a label that is located in the Footer Template of
> my DataGrid. I want this to be displayed in a label instead of a
> textbox when the user wants to add a new record because I don't want
> them to have mess with this field.
>
> -----
> Dim ds as new dataset
> Dim objCommand as new oledbCommand(strSQL, objConn)
> Dim myCommand as new OleDbDataAdapter(strSQL, objConn)
>
> myCommand.Fill(ds, "DataTable")
> lblID.text = ds.Tables("DataTable").Rows(0)("ID")
> -----
>
> When I run the page nothing is displayed in the footer for this field.
> I figured this way would work simply because the datagrid's datasource
> is the same dataset. Since the dataset is already filled I should just
> be able to grab the ID from the dataset right? Any suggestions?
>
>
> ---
> "Our enemies are innovative and resourceful, and so are we. They never
> stop thinking of ways to harm our country and our people, and neither do
> we." President George W. Bush
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
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
how to assign a ddbb value to a label using two tables rcast ASP General 0 06-14-2012 06:37 AM
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner ASP .Net 0 04-09-2007 09:00 PM
Any way to reorder how a datagrid is drawn (header/footer/items vs.header/items/footer)? Henrik ASP .Net Datagrid Control 1 07-06-2006 12:23 AM
RE: how to programmatically assign text to a label control within a da ASP .Net 1 06-06-2006 09:40 AM
how to programmatically assign text to a label control within a datalist template? ASP .Net 1 06-05-2006 07:37 PM



Advertisments