hello experts. as per the my last problem was this now i'm moing further in this repeater i want button for delete and Update. i had try but didn't work i want the button based on user authentication.
for e.g.
if user is Emplyee so he/she can edit when they click on edit one textbox should be come for edit and all the text should be come on that text box. and after that one save and cancel button should be visible. on respected button shuold work for as per their name

and if user is admin then he/she can delete the post.
And how to write query on those button for update that nested repeaters.
Help me thiis problem
Thank you.

Recommended Answers

All 10 Replies

Do you have any type of flag to determine whether the user is employee or admin ? If you have such type of flag then you can set the visibility of buttons based on this flag.

hello experts. as per the my last problem was this now i'm moing further in this repeater i want button for delete and Update. i had try but didn't work i want the button based on user authentication.
for e.g.
if user is Emplyee so he/she can edit when they click on edit one textbox should be come for edit and all the text should be come on that text box. and after that one save and cancel button should be visible. on respected button shuold work for as per their name

and if user is admin then he/she can delete the post.
And how to write query on those button for update that nested repeaters.
Help me thiis problem
Thank you.

It can be done at DataBound Event..

In DataBound Event Search for Buttoncontrol if current User is not in Admin Role and Make Button visible propety false;

hope that helps

Do you have any type of flag to determine whether the user is employee or admin ? If you have such type of flag then you can set the visibility of buttons based on this flag.

when user user login that time i'm add the Employee rights in session. and over here i want to check the if the employee is same name as the login and as per he's rights i want to show them button.

You can check using sessions if admin or he/she.
Maybe you can use like this. If admin session is admin, if others session is user.

In repeater itemdatabound you should control the session and define your button and textbox. If session is admin show delete button, else show edit button.
Just it.

hello everyone for help me but i got the soltuion how to show a button and it works very fine but the problem how to use button event inside a repeater. when i click up.down with this code for tryl it gives error. see this code else tell me code how to use button inside a repeater.

If e.Item.ItemType = ListItemType.Item Then  
            Dim up As Button = CType(e.Item.FindControl("btnuo"), Button)
            up.CommandArgument = e.Item.ItemIndex.ToString()
        End If
''this is done ItemDataBound event of repeater
Sub btnup_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Response.Write("<h1>click</h1>")
    End Sub

You should use ItemCommand event for repeater.
Add itemcommandname or commandname to button and in repeater itemcommand if(e.command == button_command_name){}

You should use ItemCommand event for repeater.
Add itemcommandname or commandname to button and in repeater itemcommand if(e.command == button_command_name){}

can you tell me some brif how to use i didn't understood about your post in ItemCommand give some e.g for this
Thanks buddy for help

<asp:Button ID="button" runat="server" CommandName="myclickevent" />
protected void Repeater_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        HiddenField hiddenId = e.Item.FindControl("hiddenId") as HiddenField;
        if (e.CommandName == "myclickevent")
        {
            // your codes here...
        }
    }

see this is my source code of repeater.

<asp:Repeater ID="Repeater1" runat="server">
        <HeaderTemplate><table></HeaderTemplate>
        <ItemTemplate>
        <tr>
             <td> 
                 <asp:Label ID="Label2" runat="server" Text="Hello"></asp:Label>
                  <asp:Button ID="Button1" runat="server" Text="Good" /></td>
             <td> <asp:Button ID="Button2" runat="server" Text="Bad" /></td>
        </tr>  
        <tr>
            <asp:Repeater ID="Repeater3" runat="server">
                <ItemTemplate>
              <td>
              <asp:Label ID="Label2" runat="server" Text="Hello"></asp:Label>
              <asp:Button ID="Button1" runat="server" Text="Edit/Delete" />
                    <asp:Button ID="Button3" runat="server" Text="Close" />    
              </td>      
                </ItemTemplate>
            </asp:Repeater>
         </tr>
        </ItemTemplate>
        <FooterTemplate></table></FooterTemplate>
        </asp:Repeater>

and even i had attached the image of my repeater a2 design time it shows
now tell me how to use this buttons click event.
Thanks

please help me yaar. In repeater when i use the button it's not Working it's event but Linkbutton is working.

<asp:Repeater ID="Repeater1" runat="server">
        <HeaderTemplate><table></HeaderTemplate>
        <ItemTemplate>
        <tr>
             <td>
                  <asp:Label ID="Label2" runat="server" Text="Hello"></asp:Label>
                  <asp:Button ID="Button1" runat="server" Text="Good" CommandName="Good"/>
            </td>
             <td> <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Bad">Bad</asp:LinkButton>
             </td>
        </tr>
          <tr>
            <asp:Repeater ID="Repeater3" runat="server">
                <ItemTemplate>
              <td>
              <asp:Label ID="Label2" runat="server" Text="Hello"></asp:Label>
              <asp:Button ID="Button1" runat="server" Text="Edit/Delete" />
                    <asp:Button ID="Button3" runat="server" Text="Close" />
                  </td>
                      </ItemTemplate>
            </asp:Repeater>
         </tr>
        </ItemTemplate>
        <FooterTemplate></table></FooterTemplate>
        </asp:Repeater>

and here is the code for the ItemCommand

Protected Sub Repeater2_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater2.ItemCommand
        If e.CommandName = "Good" Then
            Dim btn As Button = e.Item.FindControl("Bottin1")
            TextBox1.Text = "you have clicked Up button"
        ElseIf e.CommandName = "Bad" Then
            Dim lnk As LinkButton = e.Item.FindControl("LinkButton4")
            TextBox1.Text = "you have clicked Up link button"
        End If
    End Sub

when i put the code in debug mode only linkbutton comes in event but when i click the button it doesn't come in the repeater Event.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.