Help Needed -- Datalist linkbutton

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

    Help Needed -- Datalist linkbutton

    Hi Folks,
    Suppose I have two link button on a page (say lnkBtn1 and
    lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically
    created control. And On the click event of the lnkBtn2 I have to add a
    datalist control.
    Using this datalist control I should be able to add edit, modify
    and cancel the items listed in this control.

    Here is how I designed. I used placeholder to add the controls dynamically
    to the page on the click events of the buttons. Everything seems to be
    working fine until I click on the edit button of the datalist control. This
    control disappears and the corresponding event handler is not raised.

    Can anyone help how to change my design to suit my needs.

    Thanks
    Bharat
  • Karl

    #2
    Re: Help Needed -- Datalist linkbutton

    Bharat,
    If I understand correctly, you are in a tricky situation....bu t its
    something worth clearly understanding and learning.

    Basically what's happening (or rather what isn't happening) is that you need
    to _reload_ the controls when the edit button is clicked. What you have is
    this:

    Link Button 1 click -->
    Control 1 loaded -->
    Edit Clicked -->
    NOTHING

    What you need is this:

    Link button 1 clicked -->
    Control 1 loaded -->
    Edit Clicked -->
    Control 1 Loaded -->
    Woohoooo

    One of the easiest ways to achieve this is to keep the name of the control
    in viewstate object. This will let you know which control to reload when
    the edit button is clicked:

    Link button 1 clicked -->
    Control 1 loaded -->
    Control name/path stored in viewstate -->
    Edit Clicked -->
    Control name/path retrieved from viewstate -->
    Control 1 Loaded -->
    Woohoooo

    Hope that helps.

    Karl

    "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
    news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...[color=blue]
    > Hi Folks,
    > Suppose I have two link button on a page (say lnkBtn1 and
    > lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically
    > created control. And On the click event of the lnkBtn2 I have to add a
    > datalist control.
    > Using this datalist control I should be able to add edit, modify
    > and cancel the items listed in this control.
    >
    > Here is how I designed. I used placeholder to add the controls dynamically
    > to the page on the click events of the buttons. Everything seems to be
    > working fine until I click on the edit button of the datalist control.[/color]
    This[color=blue]
    > control disappears and the corresponding event handler is not raised.
    >
    > Can anyone help how to change my design to suit my needs.
    >
    > Thanks
    > Bharat[/color]


    Comment

    • Bharat

      #3
      Re: Help Needed -- Datalist linkbutton

      Karl,
      I thought I figured it out but now I am facing a different kind of
      problem. When I click on edit of the datalist the controls defined in the
      edit control show up as they should be. I change some values and then click
      update. Update event is never raised.

      What can casue this problem. I am loading the datalist into a placeholder
      each each round trip to the server since I load this datalist dynamically.

      What could be the problem.

      Thanks
      Bharat



      "Karl" wrote:
      [color=blue]
      > Bharat,
      > If I understand correctly, you are in a tricky situation....bu t its
      > something worth clearly understanding and learning.
      >
      > Basically what's happening (or rather what isn't happening) is that you need
      > to _reload_ the controls when the edit button is clicked. What you have is
      > this:
      >
      > Link Button 1 click -->
      > Control 1 loaded -->
      > Edit Clicked -->
      > NOTHING
      >
      > What you need is this:
      >
      > Link button 1 clicked -->
      > Control 1 loaded -->
      > Edit Clicked -->
      > Control 1 Loaded -->
      > Woohoooo
      >
      > One of the easiest ways to achieve this is to keep the name of the control
      > in viewstate object. This will let you know which control to reload when
      > the edit button is clicked:
      >
      > Link button 1 clicked -->
      > Control 1 loaded -->
      > Control name/path stored in viewstate -->
      > Edit Clicked -->
      > Control name/path retrieved from viewstate -->
      > Control 1 Loaded -->
      > Woohoooo
      >
      > Hope that helps.
      >
      > Karl
      >
      > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
      > news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...[color=green]
      > > Hi Folks,
      > > Suppose I have two link button on a page (say lnkBtn1 and
      > > lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically
      > > created control. And On the click event of the lnkBtn2 I have to add a
      > > datalist control.
      > > Using this datalist control I should be able to add edit, modify
      > > and cancel the items listed in this control.
      > >
      > > Here is how I designed. I used placeholder to add the controls dynamically
      > > to the page on the click events of the buttons. Everything seems to be
      > > working fine until I click on the edit button of the datalist control.[/color]
      > This[color=green]
      > > control disappears and the corresponding event handler is not raised.
      > >
      > > Can anyone help how to change my design to suit my needs.
      > >
      > > Thanks
      > > Bharat[/color]
      >
      >
      >[/color]

      Comment

      • Karl

        #4
        Re: Help Needed -- Datalist linkbutton

        not 100%...are you rebinding the datalist each time? You should only bind
        it the first time I think...

        Karl

        "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
        news:6049D0CB-30D9-4EDF-A8D8-881ACA4C4B4E@mi crosoft.com...[color=blue]
        > Karl,
        > I thought I figured it out but now I am facing a different kind of
        > problem. When I click on edit of the datalist the controls defined in the
        > edit control show up as they should be. I change some values and then[/color]
        click[color=blue]
        > update. Update event is never raised.
        >
        > What can casue this problem. I am loading the datalist into a placeholder
        > each each round trip to the server since I load this datalist dynamically.
        >
        > What could be the problem.
        >
        > Thanks
        > Bharat
        >
        >
        >
        > "Karl" wrote:
        >[color=green]
        > > Bharat,
        > > If I understand correctly, you are in a tricky situation....bu t its
        > > something worth clearly understanding and learning.
        > >
        > > Basically what's happening (or rather what isn't happening) is that you[/color][/color]
        need[color=blue][color=green]
        > > to _reload_ the controls when the edit button is clicked. What you have[/color][/color]
        is[color=blue][color=green]
        > > this:
        > >
        > > Link Button 1 click -->
        > > Control 1 loaded -->
        > > Edit Clicked -->
        > > NOTHING
        > >
        > > What you need is this:
        > >
        > > Link button 1 clicked -->
        > > Control 1 loaded -->
        > > Edit Clicked -->
        > > Control 1 Loaded -->
        > > Woohoooo
        > >
        > > One of the easiest ways to achieve this is to keep the name of the[/color][/color]
        control[color=blue][color=green]
        > > in viewstate object. This will let you know which control to reload[/color][/color]
        when[color=blue][color=green]
        > > the edit button is clicked:
        > >
        > > Link button 1 clicked -->
        > > Control 1 loaded -->
        > > Control name/path stored in viewstate -->
        > > Edit Clicked -->
        > > Control name/path retrieved from viewstate -->
        > > Control 1 Loaded -->
        > > Woohoooo
        > >
        > > Hope that helps.
        > >
        > > Karl
        > >
        > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
        > > news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...[color=darkred]
        > > > Hi Folks,
        > > > Suppose I have two link button on a page (say lnkBtn1 and
        > > > lnkBtn2). On the click event of the lnkbtn1 I have to add a[/color][/color][/color]
        dynamically[color=blue][color=green][color=darkred]
        > > > created control. And On the click event of the lnkBtn2 I have to add a
        > > > datalist control.
        > > > Using this datalist control I should be able to add edit,[/color][/color][/color]
        modify[color=blue][color=green][color=darkred]
        > > > and cancel the items listed in this control.
        > > >
        > > > Here is how I designed. I used placeholder to add the controls[/color][/color][/color]
        dynamically[color=blue][color=green][color=darkred]
        > > > to the page on the click events of the buttons. Everything seems to be
        > > > working fine until I click on the edit button of the datalist control.[/color]
        > > This[color=darkred]
        > > > control disappears and the corresponding event handler is not raised.
        > > >
        > > > Can anyone help how to change my design to suit my needs.
        > > >
        > > > Thanks
        > > > Bharat[/color]
        > >
        > >
        > >[/color][/color]


        Comment

        • Bharat

          #5
          Re: Help Needed -- Datalist linkbutton

          Hi karl,
          Yeah I was rebinding the datalist in each roundtrip. But the problem is if
          I don't rebind, the datalist control doesnot show up. So how do I do this.

          Any Help??

          Thanks
          Bharat


          "Karl" wrote:
          [color=blue]
          > not 100%...are you rebinding the datalist each time? You should only bind
          > it the first time I think...
          >
          > Karl
          >
          > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
          > news:6049D0CB-30D9-4EDF-A8D8-881ACA4C4B4E@mi crosoft.com...[color=green]
          > > Karl,
          > > I thought I figured it out but now I am facing a different kind of
          > > problem. When I click on edit of the datalist the controls defined in the
          > > edit control show up as they should be. I change some values and then[/color]
          > click[color=green]
          > > update. Update event is never raised.
          > >
          > > What can casue this problem. I am loading the datalist into a placeholder
          > > each each round trip to the server since I load this datalist dynamically.
          > >
          > > What could be the problem.
          > >
          > > Thanks
          > > Bharat
          > >
          > >
          > >
          > > "Karl" wrote:
          > >[color=darkred]
          > > > Bharat,
          > > > If I understand correctly, you are in a tricky situation....bu t its
          > > > something worth clearly understanding and learning.
          > > >
          > > > Basically what's happening (or rather what isn't happening) is that you[/color][/color]
          > need[color=green][color=darkred]
          > > > to _reload_ the controls when the edit button is clicked. What you have[/color][/color]
          > is[color=green][color=darkred]
          > > > this:
          > > >
          > > > Link Button 1 click -->
          > > > Control 1 loaded -->
          > > > Edit Clicked -->
          > > > NOTHING
          > > >
          > > > What you need is this:
          > > >
          > > > Link button 1 clicked -->
          > > > Control 1 loaded -->
          > > > Edit Clicked -->
          > > > Control 1 Loaded -->
          > > > Woohoooo
          > > >
          > > > One of the easiest ways to achieve this is to keep the name of the[/color][/color]
          > control[color=green][color=darkred]
          > > > in viewstate object. This will let you know which control to reload[/color][/color]
          > when[color=green][color=darkred]
          > > > the edit button is clicked:
          > > >
          > > > Link button 1 clicked -->
          > > > Control 1 loaded -->
          > > > Control name/path stored in viewstate -->
          > > > Edit Clicked -->
          > > > Control name/path retrieved from viewstate -->
          > > > Control 1 Loaded -->
          > > > Woohoooo
          > > >
          > > > Hope that helps.
          > > >
          > > > Karl
          > > >
          > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
          > > > news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...
          > > > > Hi Folks,
          > > > > Suppose I have two link button on a page (say lnkBtn1 and
          > > > > lnkBtn2). On the click event of the lnkbtn1 I have to add a[/color][/color]
          > dynamically[color=green][color=darkred]
          > > > > created control. And On the click event of the lnkBtn2 I have to add a
          > > > > datalist control.
          > > > > Using this datalist control I should be able to add edit,[/color][/color]
          > modify[color=green][color=darkred]
          > > > > and cancel the items listed in this control.
          > > > >
          > > > > Here is how I designed. I used placeholder to add the controls[/color][/color]
          > dynamically[color=green][color=darkred]
          > > > > to the page on the click events of the buttons. Everything seems to be
          > > > > working fine until I click on the edit button of the datalist control.
          > > > This
          > > > > control disappears and the corresponding event handler is not raised.
          > > > >
          > > > > Can anyone help how to change my design to suit my needs.
          > > > >
          > > > > Thanks
          > > > > Bharat
          > > >
          > > >
          > > >[/color][/color]
          >
          >
          >[/color]

          Comment

          • Karl

            #6
            Re: Help Needed -- Datalist linkbutton

            I think I need more information...w here's the update button located? Is it
            on the same control as the datagrid? it it a button inside the datagrid
            (like the edit button).

            Perhaps additional code would be useful to me..

            Karl

            "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
            news:F2CA6B93-2C67-4CD9-9F14-ECEEA18AB28E@mi crosoft.com...[color=blue]
            > Hi karl,
            > Yeah I was rebinding the datalist in each roundtrip. But the problem is[/color]
            if[color=blue]
            > I don't rebind, the datalist control doesnot show up. So how do I do this.
            >
            > Any Help??
            >
            > Thanks
            > Bharat
            >
            >
            > "Karl" wrote:
            >[color=green]
            > > not 100%...are you rebinding the datalist each time? You should only[/color][/color]
            bind[color=blue][color=green]
            > > it the first time I think...
            > >
            > > Karl
            > >
            > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
            > > news:6049D0CB-30D9-4EDF-A8D8-881ACA4C4B4E@mi crosoft.com...[color=darkred]
            > > > Karl,
            > > > I thought I figured it out but now I am facing a different kind[/color][/color][/color]
            of[color=blue][color=green][color=darkred]
            > > > problem. When I click on edit of the datalist the controls defined in[/color][/color][/color]
            the[color=blue][color=green][color=darkred]
            > > > edit control show up as they should be. I change some values and then[/color]
            > > click[color=darkred]
            > > > update. Update event is never raised.
            > > >
            > > > What can casue this problem. I am loading the datalist into a[/color][/color][/color]
            placeholder[color=blue][color=green][color=darkred]
            > > > each each round trip to the server since I load this datalist[/color][/color][/color]
            dynamically.[color=blue][color=green][color=darkred]
            > > >
            > > > What could be the problem.
            > > >
            > > > Thanks
            > > > Bharat
            > > >
            > > >
            > > >
            > > > "Karl" wrote:
            > > >
            > > > > Bharat,
            > > > > If I understand correctly, you are in a tricky situation....bu t its
            > > > > something worth clearly understanding and learning.
            > > > >
            > > > > Basically what's happening (or rather what isn't happening) is that[/color][/color][/color]
            you[color=blue][color=green]
            > > need[color=darkred]
            > > > > to _reload_ the controls when the edit button is clicked. What you[/color][/color][/color]
            have[color=blue][color=green]
            > > is[color=darkred]
            > > > > this:
            > > > >
            > > > > Link Button 1 click -->
            > > > > Control 1 loaded -->
            > > > > Edit Clicked -->
            > > > > NOTHING
            > > > >
            > > > > What you need is this:
            > > > >
            > > > > Link button 1 clicked -->
            > > > > Control 1 loaded -->
            > > > > Edit Clicked -->
            > > > > Control 1 Loaded -->
            > > > > Woohoooo
            > > > >
            > > > > One of the easiest ways to achieve this is to keep the name of the[/color]
            > > control[color=darkred]
            > > > > in viewstate object. This will let you know which control to reload[/color]
            > > when[color=darkred]
            > > > > the edit button is clicked:
            > > > >
            > > > > Link button 1 clicked -->
            > > > > Control 1 loaded -->
            > > > > Control name/path stored in viewstate -->
            > > > > Edit Clicked -->
            > > > > Control name/path retrieved from viewstate -->
            > > > > Control 1 Loaded -->
            > > > > Woohoooo
            > > > >
            > > > > Hope that helps.
            > > > >
            > > > > Karl
            > > > >
            > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
            > > > > news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...
            > > > > > Hi Folks,
            > > > > > Suppose I have two link button on a page (say lnkBtn1[/color][/color][/color]
            and[color=blue][color=green][color=darkred]
            > > > > > lnkBtn2). On the click event of the lnkbtn1 I have to add a[/color]
            > > dynamically[color=darkred]
            > > > > > created control. And On the click event of the lnkBtn2 I have to[/color][/color][/color]
            add a[color=blue][color=green][color=darkred]
            > > > > > datalist control.
            > > > > > Using this datalist control I should be able to add[/color][/color][/color]
            edit,[color=blue][color=green]
            > > modify[color=darkred]
            > > > > > and cancel the items listed in this control.
            > > > > >
            > > > > > Here is how I designed. I used placeholder to add the controls[/color]
            > > dynamically[color=darkred]
            > > > > > to the page on the click events of the buttons. Everything seems[/color][/color][/color]
            to be[color=blue][color=green][color=darkred]
            > > > > > working fine until I click on the edit button of the datalist[/color][/color][/color]
            control.[color=blue][color=green][color=darkred]
            > > > > This
            > > > > > control disappears and the corresponding event handler is not[/color][/color][/color]
            raised.[color=blue][color=green][color=darkred]
            > > > > >
            > > > > > Can anyone help how to change my design to suit my needs.
            > > > > >
            > > > > > Thanks
            > > > > > Bharat
            > > > >
            > > > >
            > > > >[/color]
            > >
            > >
            > >[/color][/color]


            Comment

            • Bharat

              #7
              Re: Help Needed -- Datalist linkbutton

              Yeah update button is in the datalist like the edit button. Here is the
              control description. When I place this directly on the form the update event
              is raised. Only when I load this datalist control into a placeholder all
              problems rise. If I don't rebind on every trip to server the control all
              together dissapears.


              <asp:datalist id="ddlMonthlyR ecurring" runat="server" Font-Size="12pt"
              BorderColor="bl ack" BorderWidth="2"
              GridLines="Both " CellPadding="5" CellSpacing="0" Font-Name="Verdana"
              HeaderStyle-BackColor="#aaa add"
              AlternatingItem Style-BackColor="Gain sboro"
              EditItemStyle-BackColor="aqua " OnEditCommand=" ddlMonthlyRecur ring_EditComman d"
              OnUpdateCommand ="ddlMonthlyRec urring_UpdateCo mmand"
              OnCancelCommand ="ddlMonthlyRec urring_CancelCo mmand"
              Width="500px">
              <HeaderTemplate >
              Monthly Recurring Bills
              </HeaderTemplate>
              <EditItemStyl e Font-Size="12px" BackColor="Lemo nChiffon"></EditItemStyle>
              <AlternatingIte mStyle BackColor="Gain sboro"></AlternatingItem Style>
              <ItemTemplate >
              <asp:LinkButt on id="button1" runat="server" Text="Edit" Width="100px"
              CommandName="ed it"></asp:LinkButton>
              <asp:Label id=lblBillName runat="server" Text='<%#
              DataBinder.Eval (Container.Data Item, "BillName") %>' Width="150px">
              </asp:Label>
              <asp:Label id=lblBillValue runat="server" Text='<%#
              DataBinder.Eval (Container.Data Item, "BillValue" ) %>' Width="150px">
              </asp:Label>
              </ItemTemplate>
              <HeaderStyle Font-Size="16px" BackColor="#AAA ADD"></HeaderStyle>
              <EditItemTempla te>
              <asp:Label id="Textbox1" runat="server" Text='Bill Name:'></asp:Label>
              <asp:TextBox id="Label_BillN ame" runat="server" Text='<%#
              DataBinder.Eval (Container.Data Item, "BillName") %>'>
              </asp:TextBox>
              <BR>
              <BR>
              <asp:Label id="Label_BillV alue" runat="server" Text='Bill
              Value:'></asp:Label>
              <asp:TextBox id=Text1 runat="server" Text='<%#
              DataBinder.Eval (Container.Data Item, "BillValue" ) %>'>
              </asp:TextBox>
              <BR>
              <BR>
              <asp:LinkButt on id="button2" runat="server" Text="Update"
              CommandName="up date" Width="30px"></asp:LinkButton>
              <asp:LinkButt on id="button3" runat="server" Text="Cancel"
              CommandName="ca ncel" Width="30px"></asp:LinkButton>
              </EditItemTemplat e>
              </asp:datalist>


              Thanks
              Bharat

              "Karl" wrote:
              [color=blue]
              > I think I need more information...w here's the update button located? Is it
              > on the same control as the datagrid? it it a button inside the datagrid
              > (like the edit button).
              >
              > Perhaps additional code would be useful to me..
              >
              > Karl
              >
              > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
              > news:F2CA6B93-2C67-4CD9-9F14-ECEEA18AB28E@mi crosoft.com...[color=green]
              > > Hi karl,
              > > Yeah I was rebinding the datalist in each roundtrip. But the problem is[/color]
              > if[color=green]
              > > I don't rebind, the datalist control doesnot show up. So how do I do this.
              > >
              > > Any Help??
              > >
              > > Thanks
              > > Bharat
              > >
              > >
              > > "Karl" wrote:
              > >[color=darkred]
              > > > not 100%...are you rebinding the datalist each time? You should only[/color][/color]
              > bind[color=green][color=darkred]
              > > > it the first time I think...
              > > >
              > > > Karl
              > > >
              > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
              > > > news:6049D0CB-30D9-4EDF-A8D8-881ACA4C4B4E@mi crosoft.com...
              > > > > Karl,
              > > > > I thought I figured it out but now I am facing a different kind[/color][/color]
              > of[color=green][color=darkred]
              > > > > problem. When I click on edit of the datalist the controls defined in[/color][/color]
              > the[color=green][color=darkred]
              > > > > edit control show up as they should be. I change some values and then
              > > > click
              > > > > update. Update event is never raised.
              > > > >
              > > > > What can casue this problem. I am loading the datalist into a[/color][/color]
              > placeholder[color=green][color=darkred]
              > > > > each each round trip to the server since I load this datalist[/color][/color]
              > dynamically.[color=green][color=darkred]
              > > > >
              > > > > What could be the problem.
              > > > >
              > > > > Thanks
              > > > > Bharat
              > > > >
              > > > >
              > > > >
              > > > > "Karl" wrote:
              > > > >
              > > > > > Bharat,
              > > > > > If I understand correctly, you are in a tricky situation....bu t its
              > > > > > something worth clearly understanding and learning.
              > > > > >
              > > > > > Basically what's happening (or rather what isn't happening) is that[/color][/color]
              > you[color=green][color=darkred]
              > > > need
              > > > > > to _reload_ the controls when the edit button is clicked. What you[/color][/color]
              > have[color=green][color=darkred]
              > > > is
              > > > > > this:
              > > > > >
              > > > > > Link Button 1 click -->
              > > > > > Control 1 loaded -->
              > > > > > Edit Clicked -->
              > > > > > NOTHING
              > > > > >
              > > > > > What you need is this:
              > > > > >
              > > > > > Link button 1 clicked -->
              > > > > > Control 1 loaded -->
              > > > > > Edit Clicked -->
              > > > > > Control 1 Loaded -->
              > > > > > Woohoooo
              > > > > >
              > > > > > One of the easiest ways to achieve this is to keep the name of the
              > > > control
              > > > > > in viewstate object. This will let you know which control to reload
              > > > when
              > > > > > the edit button is clicked:
              > > > > >
              > > > > > Link button 1 clicked -->
              > > > > > Control 1 loaded -->
              > > > > > Control name/path stored in viewstate -->
              > > > > > Edit Clicked -->
              > > > > > Control name/path retrieved from viewstate -->
              > > > > > Control 1 Loaded -->
              > > > > > Woohoooo
              > > > > >
              > > > > > Hope that helps.
              > > > > >
              > > > > > Karl
              > > > > >
              > > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
              > > > > > news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...
              > > > > > > Hi Folks,
              > > > > > > Suppose I have two link button on a page (say lnkBtn1[/color][/color]
              > and[color=green][color=darkred]
              > > > > > > lnkBtn2). On the click event of the lnkbtn1 I have to add a
              > > > dynamically
              > > > > > > created control. And On the click event of the lnkBtn2 I have to[/color][/color]
              > add a[color=green][color=darkred]
              > > > > > > datalist control.
              > > > > > > Using this datalist control I should be able to add[/color][/color]
              > edit,[color=green][color=darkred]
              > > > modify
              > > > > > > and cancel the items listed in this control.
              > > > > > >
              > > > > > > Here is how I designed. I used placeholder to add the controls
              > > > dynamically
              > > > > > > to the page on the click events of the buttons. Everything seems[/color][/color]
              > to be[color=green][color=darkred]
              > > > > > > working fine until I click on the edit button of the datalist[/color][/color]
              > control.[color=green][color=darkred]
              > > > > > This
              > > > > > > control disappears and the corresponding event handler is not[/color][/color]
              > raised.[color=green][color=darkred]
              > > > > > >
              > > > > > > Can anyone help how to change my design to suit my needs.
              > > > > > >
              > > > > > > Thanks
              > > > > > > Bharat
              > > > > >
              > > > > >
              > > > > >
              > > >
              > > >
              > > >[/color][/color]
              >
              >
              >[/color]

              Comment

              • Karl

                #8
                Re: Help Needed -- Datalist linkbutton

                Here's how I got it working, this is the codebehind for my usercontrol:

                private void Page_Load(objec t sender, EventArgs e) {
                if(!((WebForm1) Page).IsControl Reloaded){
                BindGrid();
                }
                }
                private void BindGrid() {
                DataTable dt = new DataTable();
                dt.Columns.Add( "BillName") ;
                dt.Columns.Add( "BillValue" );
                for (int i = 0; i < 5; i++){
                DataRow dr = dt.NewRow();
                dr[0] = 1*(i + 1);
                dr[1] = 3*(i + 1);
                dt.Rows.Add(dr) ;
                }
                grdUpload.DataS ource = dt;
                grdUpload.DataB ind();
                }
                protected void ddlMonthlyRecur ring_EditComman d(object sender,
                DataListCommand EventArgs e) {
                grdUpload.EditI temIndex = e.Item.ItemInde x;
                BindGrid();

                }
                protected void ddlMonthlyRecur ring_UpdateComm and(object sender,
                DataListCommand EventArgs e) {
                TextBox Label_BillName =
                (TextBox)e.Item .FindControl("L abel_BillName") ;
                //do whatever
                }

                Now, the only tricky part is the code in the Page_Load. As you can see, it
                used the isControlReload ed of the Page to see if this is an internal
                postback (you can't simply use Page.IsPostBack because then it won't work
                the first time around). This is what the WebForm1 page codebehind looks
                like:

                public bool IsControlReload ed = false;
                protected LinkButton lnk;
                protected PlaceHolder plc;
                private void Page_Load(objec t sender, EventArgs e) {
                string c = (string)ViewSta te["c"];
                if (c != null){
                isControlReload ed = true;
                plc.Controls.Ad d(Page.LoadCont rol(c));
                }
                }
                private void lnk_Click(objec t sender, EventArgs e) {
                ViewState.Add(" c", "u1.ascx");
                plc.Controls.Ad d(Page.LoadCont rol("u1.ascx")) ;
                }


                I hope that helps.

                Karl

                "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                news:7CFC8465-E865-42D4-A2B7-0C68D2F6CE64@mi crosoft.com...[color=blue]
                > Yeah update button is in the datalist like the edit button. Here is the
                > control description. When I place this directly on the form the update[/color]
                event[color=blue]
                > is raised. Only when I load this datalist control into a placeholder all
                > problems rise. If I don't rebind on every trip to server the control all
                > together dissapears.
                >
                >
                > <asp:datalist id="ddlMonthlyR ecurring" runat="server" Font-Size="12pt"
                > BorderColor="bl ack" BorderWidth="2"
                > GridLines="Both " CellPadding="5" CellSpacing="0" Font-Name="Verdana"
                > HeaderStyle-BackColor="#aaa add"
                > AlternatingItem Style-BackColor="Gain sboro"
                > EditItemStyle-BackColor="aqua "[/color]
                OnEditCommand=" ddlMonthlyRecur ring_EditComman d"[color=blue]
                > OnUpdateCommand ="ddlMonthlyRec urring_UpdateCo mmand"
                > OnCancelCommand ="ddlMonthlyRec urring_CancelCo mmand"
                > Width="500px">
                > <HeaderTemplate >
                > Monthly Recurring Bills
                > </HeaderTemplate>
                > <EditItemStyl e Font-Size="12px" BackColor="Lemo nChiffon"></EditItemStyle>
                > <AlternatingIte mStyle BackColor="Gain sboro"></AlternatingItem Style>
                > <ItemTemplate >
                > <asp:LinkButt on id="button1" runat="server" Text="Edit" Width="100px"
                > CommandName="ed it"></asp:LinkButton>
                > <asp:Label id=lblBillName runat="server" Text='<%#
                > DataBinder.Eval (Container.Data Item, "BillName") %>' Width="150px">
                > </asp:Label>
                > <asp:Label id=lblBillValue runat="server" Text='<%#
                > DataBinder.Eval (Container.Data Item, "BillValue" ) %>' Width="150px">
                > </asp:Label>
                > </ItemTemplate>
                > <HeaderStyle Font-Size="16px" BackColor="#AAA ADD"></HeaderStyle>
                > <EditItemTempla te>
                > <asp:Label id="Textbox1" runat="server" Text='Bill Name:'></asp:Label>
                > <asp:TextBox id="Label_BillN ame" runat="server" Text='<%#
                > DataBinder.Eval (Container.Data Item, "BillName") %>'>
                > </asp:TextBox>
                > <BR>
                > <BR>
                > <asp:Label id="Label_BillV alue" runat="server" Text='Bill
                > Value:'></asp:Label>
                > <asp:TextBox id=Text1 runat="server" Text='<%#
                > DataBinder.Eval (Container.Data Item, "BillValue" ) %>'>
                > </asp:TextBox>
                > <BR>
                > <BR>
                > <asp:LinkButt on id="button2" runat="server" Text="Update"
                > CommandName="up date" Width="30px"></asp:LinkButton>
                > <asp:LinkButt on id="button3" runat="server" Text="Cancel"
                > CommandName="ca ncel" Width="30px"></asp:LinkButton>
                > </EditItemTemplat e>
                > </asp:datalist>
                >
                >
                > Thanks
                > Bharat
                >
                > "Karl" wrote:
                >[color=green]
                > > I think I need more information...w here's the update button located? Is[/color][/color]
                it[color=blue][color=green]
                > > on the same control as the datagrid? it it a button inside the datagrid
                > > (like the edit button).
                > >
                > > Perhaps additional code would be useful to me..
                > >
                > > Karl
                > >
                > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                > > news:F2CA6B93-2C67-4CD9-9F14-ECEEA18AB28E@mi crosoft.com...[color=darkred]
                > > > Hi karl,
                > > > Yeah I was rebinding the datalist in each roundtrip. But the problem[/color][/color][/color]
                is[color=blue][color=green]
                > > if[color=darkred]
                > > > I don't rebind, the datalist control doesnot show up. So how do I do[/color][/color][/color]
                this.[color=blue][color=green][color=darkred]
                > > >
                > > > Any Help??
                > > >
                > > > Thanks
                > > > Bharat
                > > >
                > > >
                > > > "Karl" wrote:
                > > >
                > > > > not 100%...are you rebinding the datalist each time? You should[/color][/color][/color]
                only[color=blue][color=green]
                > > bind[color=darkred]
                > > > > it the first time I think...
                > > > >
                > > > > Karl
                > > > >
                > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                > > > > news:6049D0CB-30D9-4EDF-A8D8-881ACA4C4B4E@mi crosoft.com...
                > > > > > Karl,
                > > > > > I thought I figured it out but now I am facing a different[/color][/color][/color]
                kind[color=blue][color=green]
                > > of[color=darkred]
                > > > > > problem. When I click on edit of the datalist the controls defined[/color][/color][/color]
                in[color=blue][color=green]
                > > the[color=darkred]
                > > > > > edit control show up as they should be. I change some values and[/color][/color][/color]
                then[color=blue][color=green][color=darkred]
                > > > > click
                > > > > > update. Update event is never raised.
                > > > > >
                > > > > > What can casue this problem. I am loading the datalist into a[/color]
                > > placeholder[color=darkred]
                > > > > > each each round trip to the server since I load this datalist[/color]
                > > dynamically.[color=darkred]
                > > > > >
                > > > > > What could be the problem.
                > > > > >
                > > > > > Thanks
                > > > > > Bharat
                > > > > >
                > > > > >
                > > > > >
                > > > > > "Karl" wrote:
                > > > > >
                > > > > > > Bharat,
                > > > > > > If I understand correctly, you are in a tricky situation....bu t[/color][/color][/color]
                its[color=blue][color=green][color=darkred]
                > > > > > > something worth clearly understanding and learning.
                > > > > > >
                > > > > > > Basically what's happening (or rather what isn't happening) is[/color][/color][/color]
                that[color=blue][color=green]
                > > you[color=darkred]
                > > > > need
                > > > > > > to _reload_ the controls when the edit button is clicked. What[/color][/color][/color]
                you[color=blue][color=green]
                > > have[color=darkred]
                > > > > is
                > > > > > > this:
                > > > > > >
                > > > > > > Link Button 1 click -->
                > > > > > > Control 1 loaded -->
                > > > > > > Edit Clicked -->
                > > > > > > NOTHING
                > > > > > >
                > > > > > > What you need is this:
                > > > > > >
                > > > > > > Link button 1 clicked -->
                > > > > > > Control 1 loaded -->
                > > > > > > Edit Clicked -->
                > > > > > > Control 1 Loaded -->
                > > > > > > Woohoooo
                > > > > > >
                > > > > > > One of the easiest ways to achieve this is to keep the name of[/color][/color][/color]
                the[color=blue][color=green][color=darkred]
                > > > > control
                > > > > > > in viewstate object. This will let you know which control to[/color][/color][/color]
                reload[color=blue][color=green][color=darkred]
                > > > > when
                > > > > > > the edit button is clicked:
                > > > > > >
                > > > > > > Link button 1 clicked -->
                > > > > > > Control 1 loaded -->
                > > > > > > Control name/path stored in viewstate -->
                > > > > > > Edit Clicked -->
                > > > > > > Control name/path retrieved from viewstate -->
                > > > > > > Control 1 Loaded -->
                > > > > > > Woohoooo
                > > > > > >
                > > > > > > Hope that helps.
                > > > > > >
                > > > > > > Karl
                > > > > > >
                > > > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                > > > > > > news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...
                > > > > > > > Hi Folks,
                > > > > > > > Suppose I have two link button on a page (say[/color][/color][/color]
                lnkBtn1[color=blue][color=green]
                > > and[color=darkred]
                > > > > > > > lnkBtn2). On the click event of the lnkbtn1 I have to add a
                > > > > dynamically
                > > > > > > > created control. And On the click event of the lnkBtn2 I have[/color][/color][/color]
                to[color=blue][color=green]
                > > add a[color=darkred]
                > > > > > > > datalist control.
                > > > > > > > Using this datalist control I should be able to add[/color]
                > > edit,[color=darkred]
                > > > > modify
                > > > > > > > and cancel the items listed in this control.
                > > > > > > >
                > > > > > > > Here is how I designed. I used placeholder to add the controls
                > > > > dynamically
                > > > > > > > to the page on the click events of the buttons. Everything[/color][/color][/color]
                seems[color=blue][color=green]
                > > to be[color=darkred]
                > > > > > > > working fine until I click on the edit button of the datalist[/color]
                > > control.[color=darkred]
                > > > > > > This
                > > > > > > > control disappears and the corresponding event handler is not[/color]
                > > raised.[color=darkred]
                > > > > > > >
                > > > > > > > Can anyone help how to change my design to suit my needs.
                > > > > > > >
                > > > > > > > Thanks
                > > > > > > > Bharat
                > > > > > >
                > > > > > >
                > > > > > >
                > > > >
                > > > >
                > > > >[/color]
                > >
                > >
                > >[/color][/color]


                Comment

                • Bharat

                  #9
                  Re: Help Needed -- Datalist linkbutton

                  Hi Karl,
                  Thankyou very much. I got it to work your way, yet there is one more
                  problem. Since I am using a placeholder to load the user controls on click
                  events of the link buttons. I had the enableviewstate property set to false
                  for the placeholder because I had to load different controls on click events
                  of those link buttons.
                  If I set the enableviewstate property to true then the place holder
                  can load the same type of controls that were loaded in the previous
                  roundtrip. For this reason I cannot load new controls into placeholder. If I
                  set to false I have to bind the datalist in the roundtrips to the server.
                  Then all the events trigerred on the datalist are lost.

                  How can I get around this and be able to load the only needed controls? Any
                  suggestions would be appretiated.

                  Thanks
                  Bharat


                  "Karl" wrote:
                  [color=blue]
                  > Here's how I got it working, this is the codebehind for my usercontrol:
                  >
                  > private void Page_Load(objec t sender, EventArgs e) {
                  > if(!((WebForm1) Page).IsControl Reloaded){
                  > BindGrid();
                  > }
                  > }
                  > private void BindGrid() {
                  > DataTable dt = new DataTable();
                  > dt.Columns.Add( "BillName") ;
                  > dt.Columns.Add( "BillValue" );
                  > for (int i = 0; i < 5; i++){
                  > DataRow dr = dt.NewRow();
                  > dr[0] = 1*(i + 1);
                  > dr[1] = 3*(i + 1);
                  > dt.Rows.Add(dr) ;
                  > }
                  > grdUpload.DataS ource = dt;
                  > grdUpload.DataB ind();
                  > }
                  > protected void ddlMonthlyRecur ring_EditComman d(object sender,
                  > DataListCommand EventArgs e) {
                  > grdUpload.EditI temIndex = e.Item.ItemInde x;
                  > BindGrid();
                  >
                  > }
                  > protected void ddlMonthlyRecur ring_UpdateComm and(object sender,
                  > DataListCommand EventArgs e) {
                  > TextBox Label_BillName =
                  > (TextBox)e.Item .FindControl("L abel_BillName") ;
                  > //do whatever
                  > }
                  >
                  > Now, the only tricky part is the code in the Page_Load. As you can see, it
                  > used the isControlReload ed of the Page to see if this is an internal
                  > postback (you can't simply use Page.IsPostBack because then it won't work
                  > the first time around). This is what the WebForm1 page codebehind looks
                  > like:
                  >
                  > public bool IsControlReload ed = false;
                  > protected LinkButton lnk;
                  > protected PlaceHolder plc;
                  > private void Page_Load(objec t sender, EventArgs e) {
                  > string c = (string)ViewSta te["c"];
                  > if (c != null){
                  > isControlReload ed = true;
                  > plc.Controls.Ad d(Page.LoadCont rol(c));
                  > }
                  > }
                  > private void lnk_Click(objec t sender, EventArgs e) {
                  > ViewState.Add(" c", "u1.ascx");
                  > plc.Controls.Ad d(Page.LoadCont rol("u1.ascx")) ;
                  > }
                  >
                  >
                  > I hope that helps.
                  >
                  > Karl
                  >
                  > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                  > news:7CFC8465-E865-42D4-A2B7-0C68D2F6CE64@mi crosoft.com...[color=green]
                  > > Yeah update button is in the datalist like the edit button. Here is the
                  > > control description. When I place this directly on the form the update[/color]
                  > event[color=green]
                  > > is raised. Only when I load this datalist control into a placeholder all
                  > > problems rise. If I don't rebind on every trip to server the control all
                  > > together dissapears.
                  > >
                  > >
                  > > <asp:datalist id="ddlMonthlyR ecurring" runat="server" Font-Size="12pt"
                  > > BorderColor="bl ack" BorderWidth="2"
                  > > GridLines="Both " CellPadding="5" CellSpacing="0" Font-Name="Verdana"
                  > > HeaderStyle-BackColor="#aaa add"
                  > > AlternatingItem Style-BackColor="Gain sboro"
                  > > EditItemStyle-BackColor="aqua "[/color]
                  > OnEditCommand=" ddlMonthlyRecur ring_EditComman d"[color=green]
                  > > OnUpdateCommand ="ddlMonthlyRec urring_UpdateCo mmand"
                  > > OnCancelCommand ="ddlMonthlyRec urring_CancelCo mmand"
                  > > Width="500px">
                  > > <HeaderTemplate >
                  > > Monthly Recurring Bills
                  > > </HeaderTemplate>
                  > > <EditItemStyl e Font-Size="12px" BackColor="Lemo nChiffon"></EditItemStyle>
                  > > <AlternatingIte mStyle BackColor="Gain sboro"></AlternatingItem Style>
                  > > <ItemTemplate >
                  > > <asp:LinkButt on id="button1" runat="server" Text="Edit" Width="100px"
                  > > CommandName="ed it"></asp:LinkButton>
                  > > <asp:Label id=lblBillName runat="server" Text='<%#
                  > > DataBinder.Eval (Container.Data Item, "BillName") %>' Width="150px">
                  > > </asp:Label>
                  > > <asp:Label id=lblBillValue runat="server" Text='<%#
                  > > DataBinder.Eval (Container.Data Item, "BillValue" ) %>' Width="150px">
                  > > </asp:Label>
                  > > </ItemTemplate>
                  > > <HeaderStyle Font-Size="16px" BackColor="#AAA ADD"></HeaderStyle>
                  > > <EditItemTempla te>
                  > > <asp:Label id="Textbox1" runat="server" Text='Bill Name:'></asp:Label>
                  > > <asp:TextBox id="Label_BillN ame" runat="server" Text='<%#
                  > > DataBinder.Eval (Container.Data Item, "BillName") %>'>
                  > > </asp:TextBox>
                  > > <BR>
                  > > <BR>
                  > > <asp:Label id="Label_BillV alue" runat="server" Text='Bill
                  > > Value:'></asp:Label>
                  > > <asp:TextBox id=Text1 runat="server" Text='<%#
                  > > DataBinder.Eval (Container.Data Item, "BillValue" ) %>'>
                  > > </asp:TextBox>
                  > > <BR>
                  > > <BR>
                  > > <asp:LinkButt on id="button2" runat="server" Text="Update"
                  > > CommandName="up date" Width="30px"></asp:LinkButton>
                  > > <asp:LinkButt on id="button3" runat="server" Text="Cancel"
                  > > CommandName="ca ncel" Width="30px"></asp:LinkButton>
                  > > </EditItemTemplat e>
                  > > </asp:datalist>
                  > >
                  > >
                  > > Thanks
                  > > Bharat
                  > >
                  > > "Karl" wrote:
                  > >[color=darkred]
                  > > > I think I need more information...w here's the update button located? Is[/color][/color]
                  > it[color=green][color=darkred]
                  > > > on the same control as the datagrid? it it a button inside the datagrid
                  > > > (like the edit button).
                  > > >
                  > > > Perhaps additional code would be useful to me..
                  > > >
                  > > > Karl
                  > > >
                  > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                  > > > news:F2CA6B93-2C67-4CD9-9F14-ECEEA18AB28E@mi crosoft.com...
                  > > > > Hi karl,
                  > > > > Yeah I was rebinding the datalist in each roundtrip. But the problem[/color][/color]
                  > is[color=green][color=darkred]
                  > > > if
                  > > > > I don't rebind, the datalist control doesnot show up. So how do I do[/color][/color]
                  > this.[color=green][color=darkred]
                  > > > >
                  > > > > Any Help??
                  > > > >
                  > > > > Thanks
                  > > > > Bharat
                  > > > >
                  > > > >
                  > > > > "Karl" wrote:
                  > > > >
                  > > > > > not 100%...are you rebinding the datalist each time? You should[/color][/color]
                  > only[color=green][color=darkred]
                  > > > bind
                  > > > > > it the first time I think...
                  > > > > >
                  > > > > > Karl
                  > > > > >
                  > > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                  > > > > > news:6049D0CB-30D9-4EDF-A8D8-881ACA4C4B4E@mi crosoft.com...
                  > > > > > > Karl,
                  > > > > > > I thought I figured it out but now I am facing a different[/color][/color]
                  > kind[color=green][color=darkred]
                  > > > of
                  > > > > > > problem. When I click on edit of the datalist the controls defined[/color][/color]
                  > in[color=green][color=darkred]
                  > > > the
                  > > > > > > edit control show up as they should be. I change some values and[/color][/color]
                  > then[color=green][color=darkred]
                  > > > > > click
                  > > > > > > update. Update event is never raised.
                  > > > > > >
                  > > > > > > What can casue this problem. I am loading the datalist into a
                  > > > placeholder
                  > > > > > > each each round trip to the server since I load this datalist
                  > > > dynamically.
                  > > > > > >
                  > > > > > > What could be the problem.
                  > > > > > >
                  > > > > > > Thanks
                  > > > > > > Bharat
                  > > > > > >
                  > > > > > >
                  > > > > > >
                  > > > > > > "Karl" wrote:
                  > > > > > >
                  > > > > > > > Bharat,
                  > > > > > > > If I understand correctly, you are in a tricky situation....bu t[/color][/color]
                  > its[color=green][color=darkred]
                  > > > > > > > something worth clearly understanding and learning.
                  > > > > > > >
                  > > > > > > > Basically what's happening (or rather what isn't happening) is[/color][/color]
                  > that[color=green][color=darkred]
                  > > > you
                  > > > > > need
                  > > > > > > > to _reload_ the controls when the edit button is clicked. What[/color][/color]
                  > you[color=green][color=darkred]
                  > > > have
                  > > > > > is
                  > > > > > > > this:
                  > > > > > > >
                  > > > > > > > Link Button 1 click -->
                  > > > > > > > Control 1 loaded -->
                  > > > > > > > Edit Clicked -->
                  > > > > > > > NOTHING
                  > > > > > > >
                  > > > > > > > What you need is this:
                  > > > > > > >
                  > > > > > > > Link button 1 clicked -->
                  > > > > > > > Control 1 loaded -->
                  > > > > > > > Edit Clicked -->
                  > > > > > > > Control 1 Loaded -->
                  > > > > > > > Woohoooo
                  > > > > > > >
                  > > > > > > > One of the easiest ways to achieve this is to keep the name of[/color][/color]
                  > the[color=green][color=darkred]
                  > > > > > control
                  > > > > > > > in viewstate object. This will let you know which control to[/color][/color]
                  > reload[color=green][color=darkred]
                  > > > > > when
                  > > > > > > > the edit button is clicked:
                  > > > > > > >
                  > > > > > > > Link button 1 clicked -->
                  > > > > > > > Control 1 loaded -->
                  > > > > > > > Control name/path stored in viewstate -->
                  > > > > > > > Edit Clicked -->
                  > > > > > > > Control name/path retrieved from viewstate -->
                  > > > > > > > Control 1 Loaded -->
                  > > > > > > > Woohoooo
                  > > > > > > >
                  > > > > > > > Hope that helps.
                  > > > > > > >
                  > > > > > > > Karl
                  > > > > > > >
                  > > > > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                  > > > > > > > news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...
                  > > > > > > > > Hi Folks,
                  > > > > > > > > Suppose I have two link button on a page (say[/color][/color]
                  > lnkBtn1[color=green][color=darkred]
                  > > > and
                  > > > > > > > > lnkBtn2). On the click event of the lnkbtn1 I have to add a
                  > > > > > dynamically
                  > > > > > > > > created control. And On the click event of the lnkBtn2 I have[/color][/color]
                  > to[color=green][color=darkred]
                  > > > add a
                  > > > > > > > > datalist control.
                  > > > > > > > > Using this datalist control I should be able to add
                  > > > edit,
                  > > > > > modify
                  > > > > > > > > and cancel the items listed in this control.
                  > > > > > > > >
                  > > > > > > > > Here is how I designed. I used placeholder to add the controls
                  > > > > > dynamically
                  > > > > > > > > to the page on the click events of the buttons. Everything[/color][/color]
                  > seems[color=green][color=darkred]
                  > > > to be
                  > > > > > > > > working fine until I click on the edit button of the datalist
                  > > > control.
                  > > > > > > > This
                  > > > > > > > > control disappears and the corresponding event handler is not
                  > > > raised.
                  > > > > > > > >
                  > > > > > > > > Can anyone help how to change my design to suit my needs.
                  > > > > > > > >
                  > > > > > > > > Thanks
                  > > > > > > > > Bharat
                  > > > > > > >
                  > > > > > > >
                  > > > > > > >
                  > > > > >
                  > > > > >
                  > > > > >
                  > > >
                  > > >
                  > > >[/color][/color]
                  >
                  >
                  >[/color]

                  Comment

                  • Karl

                    #10
                    Re: Help Needed -- Datalist linkbutton

                    I'm not sure I can help... When enableviewstate =true, if you click button 1
                    then button 2, it'll append one control after another, is that what you are
                    saying the problem is? It won't do that if you set enableviewstate ="false",
                    but then you lose your events.

                    I can think of 3 solutions..not sure if they'll actually work though

                    [a] - in the click events of your buttons call placeholder.con trols.Clear()
                    Page_Load will get called, in the viewstate it will see "control1.a scx" so
                    it'll load it
                    the Button2 event will fire, it will clear the control1.ascx and load
                    control2.ascx
                    You are still going to have the performance of loading 2, but only 1 will
                    get displayed

                    [b] - Look at Request.Form["__EVENTTAR GET"] in the page_load and in
                    conjuction with what's in the viewstate you might be able to figure out (and
                    get away with) loading the right control (dunno about this)

                    [c] - instead of using linkbuttons and postback, use normal <a tags with a
                    querystring. This will let you know which "event" to load in the
                    page_load - which is really your problem.
                    Page_Loads, sees no querystring, doesn't do anything
                    ATag 1 clicked, Page_Loads sees ?Blah=1 and loads the first user
                    control1.ascx
                    editbutton clicked in control1.ascx, querystring will still be ?Blah=1
                    (asp.net maintains querystring on postback), Page_Load will reaload
                    control1.ascx and events should tie
                    ATag 2 clicked, page_loads sees ?blah=2, control1.ascx is NEVER loaded,
                    control2.ascx is loaded

                    Hope one of those works.

                    Karl


                    "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                    news:5A4DCB4B-9309-4E6E-B70E-7B25EB0CEC8E@mi crosoft.com...[color=blue]
                    > Hi Karl,
                    > Thankyou very much. I got it to work your way, yet there is one[/color]
                    more[color=blue]
                    > problem. Since I am using a placeholder to load the user controls on click
                    > events of the link buttons. I had the enableviewstate property set to[/color]
                    false[color=blue]
                    > for the placeholder because I had to load different controls on click[/color]
                    events[color=blue]
                    > of those link buttons.
                    > If I set the enableviewstate property to true then the place[/color]
                    holder[color=blue]
                    > can load the same type of controls that were loaded in the previous
                    > roundtrip. For this reason I cannot load new controls into placeholder. If[/color]
                    I[color=blue]
                    > set to false I have to bind the datalist in the roundtrips to the server.
                    > Then all the events trigerred on the datalist are lost.
                    >
                    > How can I get around this and be able to load the only needed controls?[/color]
                    Any[color=blue]
                    > suggestions would be appretiated.
                    >
                    > Thanks
                    > Bharat
                    >
                    >
                    > "Karl" wrote:
                    >[color=green]
                    > > Here's how I got it working, this is the codebehind for my usercontrol:
                    > >
                    > > private void Page_Load(objec t sender, EventArgs e) {
                    > > if(!((WebForm1) Page).IsControl Reloaded){
                    > > BindGrid();
                    > > }
                    > > }
                    > > private void BindGrid() {
                    > > DataTable dt = new DataTable();
                    > > dt.Columns.Add( "BillName") ;
                    > > dt.Columns.Add( "BillValue" );
                    > > for (int i = 0; i < 5; i++){
                    > > DataRow dr = dt.NewRow();
                    > > dr[0] = 1*(i + 1);
                    > > dr[1] = 3*(i + 1);
                    > > dt.Rows.Add(dr) ;
                    > > }
                    > > grdUpload.DataS ource = dt;
                    > > grdUpload.DataB ind();
                    > > }
                    > > protected void ddlMonthlyRecur ring_EditComman d(object sender,
                    > > DataListCommand EventArgs e) {
                    > > grdUpload.EditI temIndex = e.Item.ItemInde x;
                    > > BindGrid();
                    > >
                    > > }
                    > > protected void ddlMonthlyRecur ring_UpdateComm and(object sender,
                    > > DataListCommand EventArgs e) {
                    > > TextBox Label_BillName =
                    > > (TextBox)e.Item .FindControl("L abel_BillName") ;
                    > > //do whatever
                    > > }
                    > >
                    > > Now, the only tricky part is the code in the Page_Load. As you can see,[/color][/color]
                    it[color=blue][color=green]
                    > > used the isControlReload ed of the Page to see if this is an internal
                    > > postback (you can't simply use Page.IsPostBack because then it won't[/color][/color]
                    work[color=blue][color=green]
                    > > the first time around). This is what the WebForm1 page codebehind looks
                    > > like:
                    > >
                    > > public bool IsControlReload ed = false;
                    > > protected LinkButton lnk;
                    > > protected PlaceHolder plc;
                    > > private void Page_Load(objec t sender, EventArgs e) {
                    > > string c = (string)ViewSta te["c"];
                    > > if (c != null){
                    > > isControlReload ed = true;
                    > > plc.Controls.Ad d(Page.LoadCont rol(c));
                    > > }
                    > > }
                    > > private void lnk_Click(objec t sender, EventArgs e) {
                    > > ViewState.Add(" c", "u1.ascx");
                    > > plc.Controls.Ad d(Page.LoadCont rol("u1.ascx")) ;
                    > > }
                    > >
                    > >
                    > > I hope that helps.
                    > >
                    > > Karl
                    > >
                    > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                    > > news:7CFC8465-E865-42D4-A2B7-0C68D2F6CE64@mi crosoft.com...[color=darkred]
                    > > > Yeah update button is in the datalist like the edit button. Here is[/color][/color][/color]
                    the[color=blue][color=green][color=darkred]
                    > > > control description. When I place this directly on the form the update[/color]
                    > > event[color=darkred]
                    > > > is raised. Only when I load this datalist control into a placeholder[/color][/color][/color]
                    all[color=blue][color=green][color=darkred]
                    > > > problems rise. If I don't rebind on every trip to server the control[/color][/color][/color]
                    all[color=blue][color=green][color=darkred]
                    > > > together dissapears.
                    > > >
                    > > >
                    > > > <asp:datalist id="ddlMonthlyR ecurring" runat="server" Font-Size="12pt"
                    > > > BorderColor="bl ack" BorderWidth="2"
                    > > > GridLines="Both " CellPadding="5" CellSpacing="0" Font-Name="Verdana"
                    > > > HeaderStyle-BackColor="#aaa add"
                    > > > AlternatingItem Style-BackColor="Gain sboro"
                    > > > EditItemStyle-BackColor="aqua "[/color]
                    > > OnEditCommand=" ddlMonthlyRecur ring_EditComman d"[color=darkred]
                    > > > OnUpdateCommand ="ddlMonthlyRec urring_UpdateCo mmand"
                    > > > OnCancelCommand ="ddlMonthlyRec urring_CancelCo mmand"
                    > > > Width="500px">
                    > > > <HeaderTemplate >
                    > > > Monthly Recurring Bills
                    > > > </HeaderTemplate>
                    > > > <EditItemStyl e Font-Size="12px"[/color][/color][/color]
                    BackColor="Lemo nChiffon"></EditItemStyle>[color=blue][color=green][color=darkred]
                    > > > <AlternatingIte mStyle BackColor="Gain sboro"></AlternatingItem Style>
                    > > > <ItemTemplate >
                    > > > <asp:LinkButt on id="button1" runat="server" Text="Edit" Width="100px"
                    > > > CommandName="ed it"></asp:LinkButton>
                    > > > <asp:Label id=lblBillName runat="server" Text='<%#
                    > > > DataBinder.Eval (Container.Data Item, "BillName") %>' Width="150px">
                    > > > </asp:Label>
                    > > > <asp:Label id=lblBillValue runat="server" Text='<%#
                    > > > DataBinder.Eval (Container.Data Item, "BillValue" ) %>' Width="150px">
                    > > > </asp:Label>
                    > > > </ItemTemplate>
                    > > > <HeaderStyle Font-Size="16px" BackColor="#AAA ADD"></HeaderStyle>
                    > > > <EditItemTempla te>
                    > > > <asp:Label id="Textbox1" runat="server" Text='Bill Name:'></asp:Label>
                    > > > <asp:TextBox id="Label_BillN ame" runat="server" Text='<%#
                    > > > DataBinder.Eval (Container.Data Item, "BillName") %>'>
                    > > > </asp:TextBox>
                    > > > <BR>
                    > > > <BR>
                    > > > <asp:Label id="Label_BillV alue" runat="server" Text='Bill
                    > > > Value:'></asp:Label>
                    > > > <asp:TextBox id=Text1 runat="server" Text='<%#
                    > > > DataBinder.Eval (Container.Data Item, "BillValue" ) %>'>
                    > > > </asp:TextBox>
                    > > > <BR>
                    > > > <BR>
                    > > > <asp:LinkButt on id="button2" runat="server" Text="Update"
                    > > > CommandName="up date" Width="30px"></asp:LinkButton>
                    > > > <asp:LinkButt on id="button3" runat="server" Text="Cancel"
                    > > > CommandName="ca ncel" Width="30px"></asp:LinkButton>
                    > > > </EditItemTemplat e>
                    > > > </asp:datalist>
                    > > >
                    > > >
                    > > > Thanks
                    > > > Bharat
                    > > >
                    > > > "Karl" wrote:
                    > > >
                    > > > > I think I need more information...w here's the update button located?[/color][/color][/color]
                    Is[color=blue][color=green]
                    > > it[color=darkred]
                    > > > > on the same control as the datagrid? it it a button inside the[/color][/color][/color]
                    datagrid[color=blue][color=green][color=darkred]
                    > > > > (like the edit button).
                    > > > >
                    > > > > Perhaps additional code would be useful to me..
                    > > > >
                    > > > > Karl
                    > > > >
                    > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                    > > > > news:F2CA6B93-2C67-4CD9-9F14-ECEEA18AB28E@mi crosoft.com...
                    > > > > > Hi karl,
                    > > > > > Yeah I was rebinding the datalist in each roundtrip. But the[/color][/color][/color]
                    problem[color=blue][color=green]
                    > > is[color=darkred]
                    > > > > if
                    > > > > > I don't rebind, the datalist control doesnot show up. So how do I[/color][/color][/color]
                    do[color=blue][color=green]
                    > > this.[color=darkred]
                    > > > > >
                    > > > > > Any Help??
                    > > > > >
                    > > > > > Thanks
                    > > > > > Bharat
                    > > > > >
                    > > > > >
                    > > > > > "Karl" wrote:
                    > > > > >
                    > > > > > > not 100%...are you rebinding the datalist each time? You should[/color]
                    > > only[color=darkred]
                    > > > > bind
                    > > > > > > it the first time I think...
                    > > > > > >
                    > > > > > > Karl
                    > > > > > >
                    > > > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                    > > > > > > news:6049D0CB-30D9-4EDF-A8D8-881ACA4C4B4E@mi crosoft.com...
                    > > > > > > > Karl,
                    > > > > > > > I thought I figured it out but now I am facing a[/color][/color][/color]
                    different[color=blue][color=green]
                    > > kind[color=darkred]
                    > > > > of
                    > > > > > > > problem. When I click on edit of the datalist the controls[/color][/color][/color]
                    defined[color=blue][color=green]
                    > > in[color=darkred]
                    > > > > the
                    > > > > > > > edit control show up as they should be. I change some values[/color][/color][/color]
                    and[color=blue][color=green]
                    > > then[color=darkred]
                    > > > > > > click
                    > > > > > > > update. Update event is never raised.
                    > > > > > > >
                    > > > > > > > What can casue this problem. I am loading the datalist into a
                    > > > > placeholder
                    > > > > > > > each each round trip to the server since I load this datalist
                    > > > > dynamically.
                    > > > > > > >
                    > > > > > > > What could be the problem.
                    > > > > > > >
                    > > > > > > > Thanks
                    > > > > > > > Bharat
                    > > > > > > >
                    > > > > > > >
                    > > > > > > >
                    > > > > > > > "Karl" wrote:
                    > > > > > > >
                    > > > > > > > > Bharat,
                    > > > > > > > > If I understand correctly, you are in a tricky[/color][/color][/color]
                    situation....bu t[color=blue][color=green]
                    > > its[color=darkred]
                    > > > > > > > > something worth clearly understanding and learning.
                    > > > > > > > >
                    > > > > > > > > Basically what's happening (or rather what isn't happening)[/color][/color][/color]
                    is[color=blue][color=green]
                    > > that[color=darkred]
                    > > > > you
                    > > > > > > need
                    > > > > > > > > to _reload_ the controls when the edit button is clicked.[/color][/color][/color]
                    What[color=blue][color=green]
                    > > you[color=darkred]
                    > > > > have
                    > > > > > > is
                    > > > > > > > > this:
                    > > > > > > > >
                    > > > > > > > > Link Button 1 click -->
                    > > > > > > > > Control 1 loaded -->
                    > > > > > > > > Edit Clicked -->
                    > > > > > > > > NOTHING
                    > > > > > > > >
                    > > > > > > > > What you need is this:
                    > > > > > > > >
                    > > > > > > > > Link button 1 clicked -->
                    > > > > > > > > Control 1 loaded -->
                    > > > > > > > > Edit Clicked -->
                    > > > > > > > > Control 1 Loaded -->
                    > > > > > > > > Woohoooo
                    > > > > > > > >
                    > > > > > > > > One of the easiest ways to achieve this is to keep the name[/color][/color][/color]
                    of[color=blue][color=green]
                    > > the[color=darkred]
                    > > > > > > control
                    > > > > > > > > in viewstate object. This will let you know which control[/color][/color][/color]
                    to[color=blue][color=green]
                    > > reload[color=darkred]
                    > > > > > > when
                    > > > > > > > > the edit button is clicked:
                    > > > > > > > >
                    > > > > > > > > Link button 1 clicked -->
                    > > > > > > > > Control 1 loaded -->
                    > > > > > > > > Control name/path stored in viewstate -->
                    > > > > > > > > Edit Clicked -->
                    > > > > > > > > Control name/path retrieved from viewstate -->
                    > > > > > > > > Control 1 Loaded -->
                    > > > > > > > > Woohoooo
                    > > > > > > > >
                    > > > > > > > > Hope that helps.
                    > > > > > > > >
                    > > > > > > > > Karl
                    > > > > > > > >
                    > > > > > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                    > > > > > > > > news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...
                    > > > > > > > > > Hi Folks,
                    > > > > > > > > > Suppose I have two link button on a page (say[/color]
                    > > lnkBtn1[color=darkred]
                    > > > > and
                    > > > > > > > > > lnkBtn2). On the click event of the lnkbtn1 I have to add[/color][/color][/color]
                    a[color=blue][color=green][color=darkred]
                    > > > > > > dynamically
                    > > > > > > > > > created control. And On the click event of the lnkBtn2 I[/color][/color][/color]
                    have[color=blue][color=green]
                    > > to[color=darkred]
                    > > > > add a
                    > > > > > > > > > datalist control.
                    > > > > > > > > > Using this datalist control I should be able to[/color][/color][/color]
                    add[color=blue][color=green][color=darkred]
                    > > > > edit,
                    > > > > > > modify
                    > > > > > > > > > and cancel the items listed in this control.
                    > > > > > > > > >
                    > > > > > > > > > Here is how I designed. I used placeholder to add the[/color][/color][/color]
                    controls[color=blue][color=green][color=darkred]
                    > > > > > > dynamically
                    > > > > > > > > > to the page on the click events of the buttons. Everything[/color]
                    > > seems[color=darkred]
                    > > > > to be
                    > > > > > > > > > working fine until I click on the edit button of the[/color][/color][/color]
                    datalist[color=blue][color=green][color=darkred]
                    > > > > control.
                    > > > > > > > > This
                    > > > > > > > > > control disappears and the corresponding event handler is[/color][/color][/color]
                    not[color=blue][color=green][color=darkred]
                    > > > > raised.
                    > > > > > > > > >
                    > > > > > > > > > Can anyone help how to change my design to suit my needs.
                    > > > > > > > > >
                    > > > > > > > > > Thanks
                    > > > > > > > > > Bharat
                    > > > > > > > >
                    > > > > > > > >
                    > > > > > > > >
                    > > > > > >
                    > > > > > >
                    > > > > > >
                    > > > >
                    > > > >
                    > > > >[/color]
                    > >
                    > >
                    > >[/color][/color]


                    Comment

                    • Bharat

                      #11
                      Re: Help Needed -- Datalist linkbutton

                      Hi,

                      I tried the first two methods that you have listed. None seems to be
                      working. What I did is just added a new placeholder for each linkbutton on
                      the page. However my page has at present only three main linkbuttons. In the
                      click event of one linkbutton I clear out the contents of the other
                      placeholder and load the one corresponding to the current one. I got a way
                      around this still keeping the enableviewstate = true.

                      I still wonder what is the best way to solve this problem though I got it to
                      work.

                      Thanks for all the help.
                      Your suggestion were very useful.

                      Thanks
                      Bharat


                      "Karl" wrote:
                      [color=blue]
                      > I'm not sure I can help... When enableviewstate =true, if you click button 1
                      > then button 2, it'll append one control after another, is that what you are
                      > saying the problem is? It won't do that if you set enableviewstate ="false",
                      > but then you lose your events.
                      >
                      > I can think of 3 solutions..not sure if they'll actually work though
                      >
                      > [a] - in the click events of your buttons call placeholder.con trols.Clear()
                      > Page_Load will get called, in the viewstate it will see "control1.a scx" so
                      > it'll load it
                      > the Button2 event will fire, it will clear the control1.ascx and load
                      > control2.ascx
                      > You are still going to have the performance of loading 2, but only 1 will
                      > get displayed
                      >
                      > [b] - Look at Request.Form["__EVENTTAR GET"] in the page_load and in
                      > conjuction with what's in the viewstate you might be able to figure out (and
                      > get away with) loading the right control (dunno about this)
                      >
                      > [c] - instead of using linkbuttons and postback, use normal <a tags with a
                      > querystring. This will let you know which "event" to load in the
                      > page_load - which is really your problem.
                      > Page_Loads, sees no querystring, doesn't do anything
                      > ATag 1 clicked, Page_Loads sees ?Blah=1 and loads the first user
                      > control1.ascx
                      > editbutton clicked in control1.ascx, querystring will still be ?Blah=1
                      > (asp.net maintains querystring on postback), Page_Load will reaload
                      > control1.ascx and events should tie
                      > ATag 2 clicked, page_loads sees ?blah=2, control1.ascx is NEVER loaded,
                      > control2.ascx is loaded
                      >
                      > Hope one of those works.
                      >
                      > Karl
                      >
                      >
                      > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                      > news:5A4DCB4B-9309-4E6E-B70E-7B25EB0CEC8E@mi crosoft.com...[color=green]
                      > > Hi Karl,
                      > > Thankyou very much. I got it to work your way, yet there is one[/color]
                      > more[color=green]
                      > > problem. Since I am using a placeholder to load the user controls on click
                      > > events of the link buttons. I had the enableviewstate property set to[/color]
                      > false[color=green]
                      > > for the placeholder because I had to load different controls on click[/color]
                      > events[color=green]
                      > > of those link buttons.
                      > > If I set the enableviewstate property to true then the place[/color]
                      > holder[color=green]
                      > > can load the same type of controls that were loaded in the previous
                      > > roundtrip. For this reason I cannot load new controls into placeholder. If[/color]
                      > I[color=green]
                      > > set to false I have to bind the datalist in the roundtrips to the server.
                      > > Then all the events trigerred on the datalist are lost.
                      > >
                      > > How can I get around this and be able to load the only needed controls?[/color]
                      > Any[color=green]
                      > > suggestions would be appretiated.
                      > >
                      > > Thanks
                      > > Bharat
                      > >
                      > >
                      > > "Karl" wrote:
                      > >[color=darkred]
                      > > > Here's how I got it working, this is the codebehind for my usercontrol:
                      > > >
                      > > > private void Page_Load(objec t sender, EventArgs e) {
                      > > > if(!((WebForm1) Page).IsControl Reloaded){
                      > > > BindGrid();
                      > > > }
                      > > > }
                      > > > private void BindGrid() {
                      > > > DataTable dt = new DataTable();
                      > > > dt.Columns.Add( "BillName") ;
                      > > > dt.Columns.Add( "BillValue" );
                      > > > for (int i = 0; i < 5; i++){
                      > > > DataRow dr = dt.NewRow();
                      > > > dr[0] = 1*(i + 1);
                      > > > dr[1] = 3*(i + 1);
                      > > > dt.Rows.Add(dr) ;
                      > > > }
                      > > > grdUpload.DataS ource = dt;
                      > > > grdUpload.DataB ind();
                      > > > }
                      > > > protected void ddlMonthlyRecur ring_EditComman d(object sender,
                      > > > DataListCommand EventArgs e) {
                      > > > grdUpload.EditI temIndex = e.Item.ItemInde x;
                      > > > BindGrid();
                      > > >
                      > > > }
                      > > > protected void ddlMonthlyRecur ring_UpdateComm and(object sender,
                      > > > DataListCommand EventArgs e) {
                      > > > TextBox Label_BillName =
                      > > > (TextBox)e.Item .FindControl("L abel_BillName") ;
                      > > > //do whatever
                      > > > }
                      > > >
                      > > > Now, the only tricky part is the code in the Page_Load. As you can see,[/color][/color]
                      > it[color=green][color=darkred]
                      > > > used the isControlReload ed of the Page to see if this is an internal
                      > > > postback (you can't simply use Page.IsPostBack because then it won't[/color][/color]
                      > work[color=green][color=darkred]
                      > > > the first time around). This is what the WebForm1 page codebehind looks
                      > > > like:
                      > > >
                      > > > public bool IsControlReload ed = false;
                      > > > protected LinkButton lnk;
                      > > > protected PlaceHolder plc;
                      > > > private void Page_Load(objec t sender, EventArgs e) {
                      > > > string c = (string)ViewSta te["c"];
                      > > > if (c != null){
                      > > > isControlReload ed = true;
                      > > > plc.Controls.Ad d(Page.LoadCont rol(c));
                      > > > }
                      > > > }
                      > > > private void lnk_Click(objec t sender, EventArgs e) {
                      > > > ViewState.Add(" c", "u1.ascx");
                      > > > plc.Controls.Ad d(Page.LoadCont rol("u1.ascx")) ;
                      > > > }
                      > > >
                      > > >
                      > > > I hope that helps.
                      > > >
                      > > > Karl
                      > > >
                      > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                      > > > news:7CFC8465-E865-42D4-A2B7-0C68D2F6CE64@mi crosoft.com...
                      > > > > Yeah update button is in the datalist like the edit button. Here is[/color][/color]
                      > the[color=green][color=darkred]
                      > > > > control description. When I place this directly on the form the update
                      > > > event
                      > > > > is raised. Only when I load this datalist control into a placeholder[/color][/color]
                      > all[color=green][color=darkred]
                      > > > > problems rise. If I don't rebind on every trip to server the control[/color][/color]
                      > all[color=green][color=darkred]
                      > > > > together dissapears.
                      > > > >
                      > > > >
                      > > > > <asp:datalist id="ddlMonthlyR ecurring" runat="server" Font-Size="12pt"
                      > > > > BorderColor="bl ack" BorderWidth="2"
                      > > > > GridLines="Both " CellPadding="5" CellSpacing="0" Font-Name="Verdana"
                      > > > > HeaderStyle-BackColor="#aaa add"
                      > > > > AlternatingItem Style-BackColor="Gain sboro"
                      > > > > EditItemStyle-BackColor="aqua "
                      > > > OnEditCommand=" ddlMonthlyRecur ring_EditComman d"
                      > > > > OnUpdateCommand ="ddlMonthlyRec urring_UpdateCo mmand"
                      > > > > OnCancelCommand ="ddlMonthlyRec urring_CancelCo mmand"
                      > > > > Width="500px">
                      > > > > <HeaderTemplate >
                      > > > > Monthly Recurring Bills
                      > > > > </HeaderTemplate>
                      > > > > <EditItemStyl e Font-Size="12px"[/color][/color]
                      > BackColor="Lemo nChiffon"></EditItemStyle>[color=green][color=darkred]
                      > > > > <AlternatingIte mStyle BackColor="Gain sboro"></AlternatingItem Style>
                      > > > > <ItemTemplate >
                      > > > > <asp:LinkButt on id="button1" runat="server" Text="Edit" Width="100px"
                      > > > > CommandName="ed it"></asp:LinkButton>
                      > > > > <asp:Label id=lblBillName runat="server" Text='<%#
                      > > > > DataBinder.Eval (Container.Data Item, "BillName") %>' Width="150px">
                      > > > > </asp:Label>
                      > > > > <asp:Label id=lblBillValue runat="server" Text='<%#
                      > > > > DataBinder.Eval (Container.Data Item, "BillValue" ) %>' Width="150px">
                      > > > > </asp:Label>
                      > > > > </ItemTemplate>
                      > > > > <HeaderStyle Font-Size="16px" BackColor="#AAA ADD"></HeaderStyle>
                      > > > > <EditItemTempla te>
                      > > > > <asp:Label id="Textbox1" runat="server" Text='Bill Name:'></asp:Label>
                      > > > > <asp:TextBox id="Label_BillN ame" runat="server" Text='<%#
                      > > > > DataBinder.Eval (Container.Data Item, "BillName") %>'>
                      > > > > </asp:TextBox>
                      > > > > <BR>
                      > > > > <BR>
                      > > > > <asp:Label id="Label_BillV alue" runat="server" Text='Bill
                      > > > > Value:'></asp:Label>
                      > > > > <asp:TextBox id=Text1 runat="server" Text='<%#
                      > > > > DataBinder.Eval (Container.Data Item, "BillValue" ) %>'>
                      > > > > </asp:TextBox>
                      > > > > <BR>
                      > > > > <BR>
                      > > > > <asp:LinkButt on id="button2" runat="server" Text="Update"
                      > > > > CommandName="up date" Width="30px"></asp:LinkButton>
                      > > > > <asp:LinkButt on id="button3" runat="server" Text="Cancel"
                      > > > > CommandName="ca ncel" Width="30px"></asp:LinkButton>
                      > > > > </EditItemTemplat e>
                      > > > > </asp:datalist>
                      > > > >
                      > > > >
                      > > > > Thanks
                      > > > > Bharat
                      > > > >
                      > > > > "Karl" wrote:
                      > > > >
                      > > > > > I think I need more information...w here's the update button located?[/color][/color]
                      > Is[color=green][color=darkred]
                      > > > it
                      > > > > > on the same control as the datagrid? it it a button inside the[/color][/color]
                      > datagrid[color=green][color=darkred]
                      > > > > > (like the edit button).
                      > > > > >
                      > > > > > Perhaps additional code would be useful to me..
                      > > > > >
                      > > > > > Karl
                      > > > > >
                      > > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                      > > > > > news:F2CA6B93-2C67-4CD9-9F14-ECEEA18AB28E@mi crosoft.com...
                      > > > > > > Hi karl,
                      > > > > > > Yeah I was rebinding the datalist in each roundtrip. But the[/color][/color]
                      > problem[color=green][color=darkred]
                      > > > is
                      > > > > > if
                      > > > > > > I don't rebind, the datalist control doesnot show up. So how do I[/color][/color]
                      > do[color=green][color=darkred]
                      > > > this.
                      > > > > > >
                      > > > > > > Any Help??
                      > > > > > >
                      > > > > > > Thanks
                      > > > > > > Bharat
                      > > > > > >
                      > > > > > >
                      > > > > > > "Karl" wrote:
                      > > > > > >
                      > > > > > > > not 100%...are you rebinding the datalist each time? You should
                      > > > only
                      > > > > > bind
                      > > > > > > > it the first time I think...
                      > > > > > > >
                      > > > > > > > Karl
                      > > > > > > >
                      > > > > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                      > > > > > > > news:6049D0CB-30D9-4EDF-A8D8-881ACA4C4B4E@mi crosoft.com...
                      > > > > > > > > Karl,
                      > > > > > > > > I thought I figured it out but now I am facing a[/color][/color]
                      > different[color=green][color=darkred]
                      > > > kind
                      > > > > > of
                      > > > > > > > > problem. When I click on edit of the datalist the controls[/color][/color]
                      > defined[color=green][color=darkred]
                      > > > in
                      > > > > > the
                      > > > > > > > > edit control show up as they should be. I change some values[/color][/color]
                      > and[color=green][color=darkred]
                      > > > then
                      > > > > > > > click
                      > > > > > > > > update. Update event is never raised.
                      > > > > > > > >
                      > > > > > > > > What can casue this problem. I am loading the datalist into a
                      > > > > > placeholder
                      > > > > > > > > each each round trip to the server since I load this datalist
                      > > > > > dynamically.
                      > > > > > > > >
                      > > > > > > > > What could be the problem.
                      > > > > > > > >
                      > > > > > > > > Thanks
                      > > > > > > > > Bharat
                      > > > > > > > >
                      > > > > > > > >
                      > > > > > > > >
                      > > > > > > > > "Karl" wrote:
                      > > > > > > > >
                      > > > > > > > > > Bharat,
                      > > > > > > > > > If I understand correctly, you are in a tricky[/color][/color]
                      > situation....bu t[color=green][color=darkred]
                      > > > its
                      > > > > > > > > > something worth clearly understanding and learning.
                      > > > > > > > > >
                      > > > > > > > > > Basically what's happening (or rather what isn't happening)[/color][/color]
                      > is[color=green][color=darkred]
                      > > > that
                      > > > > > you
                      > > > > > > > need
                      > > > > > > > > > to _reload_ the controls when the edit button is clicked.[/color][/color]
                      > What[color=green][color=darkred]
                      > > > you
                      > > > > > have
                      > > > > > > > is
                      > > > > > > > > > this:
                      > > > > > > > > >
                      > > > > > > > > > Link Button 1 click -->
                      > > > > > > > > > Control 1 loaded -->
                      > > > > > > > > > Edit Clicked -->
                      > > > > > > > > > NOTHING
                      > > > > > > > > >
                      > > > > > > > > > What you need is this:
                      > > > > > > > > >
                      > > > > > > > > > Link button 1 clicked -->
                      > > > > > > > > > Control 1 loaded -->
                      > > > > > > > > > Edit Clicked -->
                      > > > > > > > > > Control 1 Loaded -->
                      > > > > > > > > > Woohoooo
                      > > > > > > > > >
                      > > > > > > > > > One of the easiest ways to achieve this is to keep the name[/color][/color]
                      > of[color=green][color=darkred]
                      > > > the
                      > > > > > > > control
                      > > > > > > > > > in viewstate object. This will let you know which control[/color][/color]
                      > to[color=green][color=darkred]
                      > > > reload
                      > > > > > > > when
                      > > > > > > > > > the edit button is clicked:
                      > > > > > > > > >
                      > > > > > > > > > Link button 1 clicked -->
                      > > > > > > > > > Control 1 loaded -->
                      > > > > > > > > > Control name/path stored in viewstate -->
                      > > > > > > > > > Edit Clicked -->
                      > > > > > > > > > Control name/path retrieved from viewstate -->
                      > > > > > > > > > Control 1 Loaded -->
                      > > > > > > > > > Woohoooo
                      > > > > > > > > >
                      > > > > > > > > > Hope that helps.
                      > > > > > > > > >
                      > > > > > > > > > Karl
                      > > > > > > > > >
                      > > > > > > > > > "Bharat" <Bharat@discuss ions.microsoft. com> wrote in message
                      > > > > > > > > > news:4E4D1A8C-6F12-41A0-9823-5F65F7C190AA@mi crosoft.com...
                      > > > > > > > > > > Hi Folks,
                      > > > > > > > > > > Suppose I have two link button on a page (say
                      > > > lnkBtn1
                      > > > > > and
                      > > > > > > > > > > lnkBtn2). On the click event of the lnkbtn1 I have to add[/color][/color]
                      > a[color=green][color=darkred]
                      > > > > > > > dynamically
                      > > > > > > > > > > created control. And On the click event of the lnkBtn2 I[/color][/color]
                      > have[color=green][color=darkred]
                      > > > to
                      > > > > > add a
                      > > > > > > > > > > datalist control.
                      > > > > > > > > > > Using this datalist control I should be able to[/color][/color]
                      > add[color=green][color=darkred]
                      > > > > > edit,
                      > > > > > > > modify
                      > > > > > > > > > > and cancel the items listed in this control.
                      > > > > > > > > > >
                      > > > > > > > > > > Here is how I designed. I used placeholder to add the[/color][/color]
                      > controls[color=green][color=darkred]
                      > > > > > > > dynamically
                      > > > > > > > > > > to the page on the click events of the buttons. Everything
                      > > > seems
                      > > > > > to be
                      > > > > > > > > > > working fine until I click on the edit button of the[/color][/color]
                      > datalist[color=green][color=darkred]
                      > > > > > control.
                      > > > > > > > > > This
                      > > > > > > > > > > control disappears and the corresponding event handler is[/color][/color]
                      > not[color=green][color=darkred]
                      > > > > > raised.
                      > > > > > > > > > >
                      > > > > > > > > > > Can anyone help how to change my design to suit my needs.
                      > > > > > > > > > >
                      > > > > > > > > > > Thanks
                      > > > > > > > > > > Bharat
                      > > > > > > > > >
                      > > > > > > > > >
                      > > > > > > > > >
                      > > > > > > >
                      > > > > > > >
                      > > > > > > >
                      > > > > >
                      > > > > >
                      > > > > >
                      > > >
                      > > >
                      > > >[/color][/color]
                      >
                      >
                      >[/color]

                      Comment

                      Working...