GridView1_RowCreated versus GridView1_RowDataBound

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben

    GridView1_RowCreated versus GridView1_RowDataBound

    Hi,

    i'm a little bit confused about the events GridView1_RowDa taBound and
    GridView1_RowCr eated.

    1) Which is executed first?
    2) if i want to fetch the value of a field using this code:
    dim a as string
    a = e.Row.Cells(2). Text

    in which event do i have to do that?

    3) there is a dropdownlist in aspx file embebbed in a template like this:
    <asp:TemplateFi eld >
    <EditItemTempla te>
    <asp:DropDownLi st ID="DropDownLis t1" runat="server" >
    </asp:DropDownLis t>
    </EditItemTemplat e>
    </asp:TemplateFie ld>

    i want to access it with this code:
    dim dd as dropdownlist
    dd = e.Row.FindContr ol("DropDownLis t1")

    in which event do i have to do that?

    Thanks
    Bob


  • Munna

    #2
    Re: GridView1_RowCr eated versus GridView1_RowDa taBound

    Hi

    "1) Which is executed first? .."

    rowcreated is execute first... then rowdatabound... .

    "2) if i want to fetch the value of a field using this code: ... in
    which event do i have to do that? "

    RowDataBound


    3) there is a dropdownlist in aspx file embebbed in a template like
    this: ....in which event do i have to do that?

    RowDataBound

    Thanks

    Munna

    Comment

    • Ben

      #3
      Re: GridView1_RowCr eated versus GridView1_RowDa taBound

      ok, thanks

      "Munna" <munnaonc@gmail .comschreef in bericht
      news:c210f4a9-f8a1-43c3-8431-92088a485c40@25 g2000hsx.google groups.com...
      Hi
      >
      "1) Which is executed first? .."
      >
      rowcreated is execute first... then rowdatabound... .
      >
      "2) if i want to fetch the value of a field using this code: ... in
      which event do i have to do that? "
      >
      RowDataBound
      >
      >
      3) there is a dropdownlist in aspx file embebbed in a template like
      this: ....in which event do i have to do that?
      >
      RowDataBound
      >
      Thanks
      >
      Munna

      Comment

      • Ben

        #4
        Re: GridView1_RowCr eated versus GridView1_RowDa taBound

        Hi again,

        i posted this but no answer, and because it has to do with this topic, maybe
        you can solve this:

        Can someone explain me why the same code with the event
        GridView1_RowDa taBound gives this error:

        'DropDownList1' has a SelectedValue which is invalid because it does not
        exist in the list of items.
        Parameter name: value

        and not with the event GridView1_RowCr eated ?

        Thanks
        Ben

        Protected Sub GridView1_RowDa taBound(ByVal sender As Object, ByVal e As

        System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles
        GridView1.RowDa taBound
        If (e.Row.RowState And DataControlRowS tate.Edit) =
        DataControlRowS tate.Edit Then
        If e.Row.RowType = DataControlRowT ype.DataRow Then
        Dim dd As DropDownList
        Dim i As Integer
        Dim z As ListItem
        dd = e.Row.FindContr ol("DropDownLis t1")
        For i = 1 To 20
        z = New ListItem(i, i)
        dd.Items.Add(z)
        Next
        End If
        End If
        End Sub




        "Munna" <munnaonc@gmail .comschreef in bericht
        news:c210f4a9-f8a1-43c3-8431-92088a485c40@25 g2000hsx.google groups.com...
        Hi
        >
        "1) Which is executed first? .."
        >
        rowcreated is execute first... then rowdatabound... .
        >
        "2) if i want to fetch the value of a field using this code: ... in
        which event do i have to do that? "
        >
        RowDataBound
        >
        >
        3) there is a dropdownlist in aspx file embebbed in a template like
        this: ....in which event do i have to do that?
        >
        RowDataBound
        >
        Thanks
        >
        Munna

        Comment

        Working...