Assign Text to Footer Label

Discussion in 'ASP .Net' started by Will Chamberlain, Oct 3, 2005.

  1. 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 ***
     
    Will Chamberlain, Oct 3, 2005
    #1
    1. Advertising

  2. 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 ***
    >
     
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Oct 3, 2005
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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 ***
     
    Trevor Benedict R, Oct 3, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    1
    Views:
    943
    =?Utf-8?B?dGlta2xpbmc=?=
    Jun 5, 2006
  2. Guest
    Replies:
    1
    Views:
    618
    Walter Wang [MSFT]
    Jun 6, 2006
  3. CSharpner
    Replies:
    0
    Views:
    1,145
    CSharpner
    Apr 9, 2007
  4. Henrik
    Replies:
    1
    Views:
    466
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
  5. Knut Krueger
    Replies:
    8
    Views:
    340
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page