Add controls in datatable

Discussion in 'ASP .Net Datagrid Control' started by Andre, Feb 27, 2004.

  1. Andre

    Andre Guest

    Hi,

    I want to add a Textbox in my datatable before binding my datagrid with
    it. But i can't find a way to do it.

    Did someone know what i'm doing wrong ?

    - If i write <asp:textbox....> the column is empty.
    - If i create my textbox on the onitemdatabind event, my textbox is on
    another line of the datagrid.
    - if i try to make it this way my colum is empty :
    Dim txtbox As New TextBox
    txtbox.Visible = True
    txtbox.Attributes.Add("runat", "server")
    txtbox.ID = "opt"
    txtbox.EnableViewState = True
    dr(1) = txtbox

    Thank you, and i paste a copy of my code below.


    Dim dt As DataTable = New DataTable
    Dim dr As DataRow
    Dim dv As DataView

    dt.Columns.Add(New DataColumn("Service", GetType(String)))
    dt.Columns.Add(New DataColumn("Option", GetType(TextBox)))
    dt.Columns.Add(New DataColumn("Install", GetType(Decimal)))
    dt.Columns.Add(New DataColumn("TypeA", GetType(String)))
    dt.Columns.Add(New DataColumn("Servicen", GetType(String)))
    dt.Columns.Add(New DataColumn("Month", GetType(Decimal)))

    if my product number = 10 ......

    dr = dt.NewRow
    dr(0) = "Product 10"
    dr(1) = *********** Create textbox here ************
    dr(2) = Prix
    dr(3) = myReader.GetString(3)
    dr(4) = String1
    dr(5) = myReader.GetValue(4)
    dt.Rows.Add(dr)

    dv = New DataView(dt)
    DataGrid1.DataSource = dv
    DataGrid1.DataBind()
    Andre, Feb 27, 2004
    #1
    1. Advertising

  2. Your post went unanswered. Have you resolved this issue?

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Andre" <> wrote in message
    news:eTcyyJV$...
    > Hi,
    >
    > I want to add a Textbox in my datatable before binding my datagrid

    with
    > it. But i can't find a way to do it.
    >
    > Did someone know what i'm doing wrong ?
    >
    > - If i write <asp:textbox....> the column is empty.
    > - If i create my textbox on the onitemdatabind event, my textbox is on
    > another line of the datagrid.
    > - if i try to make it this way my colum is empty :
    > Dim txtbox As New TextBox
    > txtbox.Visible = True
    > txtbox.Attributes.Add("runat", "server")
    > txtbox.ID = "opt"
    > txtbox.EnableViewState = True
    > dr(1) = txtbox
    >
    > Thank you, and i paste a copy of my code below.
    >
    >
    > Dim dt As DataTable = New DataTable
    > Dim dr As DataRow
    > Dim dv As DataView
    >
    > dt.Columns.Add(New DataColumn("Service", GetType(String)))
    > dt.Columns.Add(New DataColumn("Option", GetType(TextBox)))
    > dt.Columns.Add(New DataColumn("Install", GetType(Decimal)))
    > dt.Columns.Add(New DataColumn("TypeA", GetType(String)))
    > dt.Columns.Add(New DataColumn("Servicen", GetType(String)))
    > dt.Columns.Add(New DataColumn("Month", GetType(Decimal)))
    >
    > if my product number = 10 ......
    >
    > dr = dt.NewRow
    > dr(0) = "Product 10"
    > dr(1) = *********** Create textbox here ************
    > dr(2) = Prix
    > dr(3) = myReader.GetString(3)
    > dr(4) = String1
    > dr(5) = myReader.GetValue(4)
    > dt.Rows.Add(dr)
    >
    > dv = New DataView(dt)
    > DataGrid1.DataSource = dv
    > DataGrid1.DataBind()
    >
    >
    Alvin Bruney [MVP], Mar 2, 2004
    #2
    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. J. Babe
    Replies:
    1
    Views:
    8,336
    Kevin Spencer
    Aug 15, 2003
  2. Fredrik Rodin

    Sort a datatable and create a new datatable

    Fredrik Rodin, Feb 16, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    9,041
    paul.mariotti
    Sep 28, 2007
  3. =?Utf-8?B?Qmx1ZWZsb3dlcg==?=

    Casting DataTable to class inherit from DataTable

    =?Utf-8?B?Qmx1ZWZsb3dlcg==?=, Apr 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    994
    =?Utf-8?B?Qmx1ZWZsb3dlcg==?=
    Apr 2, 2004
  4. jg
    Replies:
    1
    Views:
    721
    =?Utf-8?B?U2hhaWxlc2ggSmFubnU=?=
    Aug 17, 2004
  5. Ersin Gençtürk
    Replies:
    1
    Views:
    3,478
    Ersin Gençtürk
    Oct 6, 2004
Loading...

Share This Page