rajeswaran25 0 Newbie Poster

first just read my aspx&aspx.cs codes then repaly me
aspx.cs code:

namespace ReceiptsEntryPro
{
    public partial class Groups : System.Web.UI.Page
    {
        RecieptBusiness objbs = new RecieptBusiness();
        string strid;
        
        
        protected void Page_Load(object sender, EventArgs e)
        {

            GlidMax();

            ItemsGet();

          //repGroups.DataSource = dsrep;
          //repGroups.DataBind();

        }

        

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strGroupName;
            string strGroupId;
            string obsolute;
            if (txtGroupName.Text.ToString() == "")
            {
                lblerror.Text = "Please Enter The Value For GroupName";
                lblerror.ForeColor = System.Drawing.Color.Red;
                lblerror.Font.Bold = true;
                lblerror.Font.Size = 10;
            }
            else
            {
                strGroupId = txtGrouid.Text.ToString();
                strGroupName = txtGroupName.Text.ToString();
                obsolute = "N";
                objbs.InsertGroupsData(strGroupId, strGroupName, obsolute);
                ItemsGet();
                LblMessage.Text = "Inserted SuccessFully";
                LblMessage.Font.Bold = true;
                LblMessage.ForeColor = System.Drawing.Color.Green;                
                GlidMax();
                txtGroupName.Text = "";
            }

        }

        protected void btnEditClick(object sender, System.EventArgs e)
        {

            ImageButton btnFindEdit = (ImageButton)sender;
            Label lblid = btnFindEdit.Parent.FindControl("lblgouid") as Label;
            Label lblname = btnFindEdit.Parent.FindControl("lblgouname") as Label;
            txtGrouid.Text = lblid.Text.ToString();
            txtGroupName.Text = lblname.Text.ToString();
            
        }
        protected void btnDeleteClick(object sender, System.EventArgs e)
        {

            ImageButton btnFindEdit = (ImageButton)sender;
            Label lblid1 = btnFindEdit.Parent.FindControl("lblgouid") as Label;
            string strlblid = lblid1.Text.ToString();
            objbs.GroupsDelete(strlblid);
            ItemsGet();
            LblMessage.Text = "Deleted SuccessFully";
            LblMessage.ForeColor = System.Drawing.Color.Green;
            txtGroupName.Text = "";
           
            GlidMax();
        }

        protected void repGroups_ItemCommand(object source, RepeaterCommandEventArgs e)
        {

        }

        protected void btnprev_Click(object sender, EventArgs e)
        {
            // Set viewstate variable to the previous page
            CurrentPage -= 1;

            // Reload control
            ItemsGet();

        }

        protected void btnnext_Click(object sender, EventArgs e)
        {
            // Set viewstate variable to the next page
            CurrentPage += 1;

            // Reload control
            ItemsGet();

        }
        public void ItemsGet()
        {
            DataSet dsrep = objbs.loadrepGroup();


            // Populate the repeater control with the Items DataSet
            PagedDataSource objPds = new PagedDataSource();
            objPds.DataSource = dsrep.Tables[0].DefaultView;
            objPds.AllowPaging = true;
            objPds.PageSize = 10;

            objPds.CurrentPageIndex = CurrentPage;

            //lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
            //    + objPds.PageCount.ToString();

            btnprev.Enabled = !objPds.IsFirstPage;
            btnnext.Enabled = !objPds.IsLastPage;

            repGroups.DataSource = objPds;
            repGroups.DataBind();
        }
        public int CurrentPage
        {
            get
            {
                // look for current page in ViewState
                object o = this.ViewState["_CurrentPage"];
                if (o == null)
                    return 0;	// default to showing the first page
                else
                    return (int)o;
            }

            set
            {
                this.ViewState["_CurrentPage"] = value;
            }
        }
        public void GlidMax()
        {
            DataSet ds = objbs.loadGroup();
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    strid = dr["glid"].ToString();

                }
            }
            int intid = Convert.ToInt16(strid);
            intid = intid + 1;
            string strconid = Convert.ToString(intid);
            strconid = "GL-" + strconid;
            txtGrouid.Text = strconid;
        }

        protected void btnClear_Click(object sender, EventArgs e)
        {
            txtGroupName.Text = "";

        }
    }
}
aspx code: 
<%@ Page Language="C#" MasterPageFile="~/Entry.Master" AutoEventWireup="true" Codebehind="Groups.aspx.cs"
    Inherits="ReceiptsEntryPro.Groups" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tblCntentGroups" cellpadding="0" cellspacing="0" width="100%" runat="server">
        <tr>
            <td>
                <asp:Label ID="lblerror" Text="" runat="server"></asp:Label>
                <asp:Label ID="LblMessage" Text ="" runat ="server" ></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                <div class="HdrTitle">
                    <asp:Button ID="btnSave" Text="Save" runat="server" CssClass="btnnormal" Width="50px"
                        OnClick="btnSave_Click" />
                    <asp:Button ID="btnSamle" Text="Sample" runat="server" CssClass="btnnormal" Width="50px" />
                    <asp:Button ID="btnClear" Text="Clear" runat="server" CssClass="btnNormal" Width="50px" />
                    <asp:Button ID="btnPrint" Text="print" runat="server" CssClass="btnNormal" Width="50px" />
                    <asp:Button ID="btnExit" Text="Exit" runat="server" CssClass="btnNormal" Width="50px" />
                </div>
            </td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td style="height: 24px">
                <asp:Label ID="lblGroupid" Text="Groupid" runat="server"  Width="100px"></asp:Label>
                <asp:TextBox ID="txtGrouid" Enabled ="false"  runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lblGroupName" Text="Groupname" runat="server" Width="100px"></asp:Label>
                <asp:TextBox ID="txtGroupName" runat="server"></asp:TextBox>
            </td>
        </tr>
    </table>
    <div>
        <asp:Repeater ID="repGroups" runat="server" OnItemCommand="repGroups_ItemCommand">
            <HeaderTemplate>
                <table class="ListShort" cellpadding="0" cellspacing="0" border="1" width="100%">
                    <tr class="Header">
                        <td>
                            <asp:Label ID="lblrepGroupid" Text="GroupId" ForeColor="black" Font-Bold="true" runat="server">
                            </asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="lblrepGroupname" Text="GroupNmae" ForeColor="black" Font-Bold="true"
                                runat="server">
                            </asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="lblrepedit" Text="Edit" ForeColor="black" Font-Bold="true" runat="server">
                            </asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="lblrepdelete" Text="Delete" ForeColor="black" Font-Bold="true" runat="server">
                            </asp:Label>
                        </td>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr class="DataLight">
                    <td>
                        <asp:Label ID="lblgouid" Text='<% #DataBinder.Eval(Container.DataItem, "GLID") %>'
                            runat="server">
                        </asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="lblgouname" Text='<% #DataBinder.Eval(Container.DataItem, "GLName") %>'
                            runat="server">
                        </asp:Label>
                    </td>
                    <td>
                        <asp:ImageButton ID="imgbtnEdit" ImageUrl="" runat="server"  OnClick="btnEditClick" CommandName="Edit" />
                    </td>
                    <td>
                        <asp:ImageButton ID="imgbtnDelete" ImageUrl="" runat="server" OnClientClick="javascript:return confirm('Do you want to delete this?');" OnClick="btnDeleteClick"  CommandName="Delete" />
                    </td>
                </tr>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr class="DataDark">
                    <td>
                        <asp:Label ID="lblgouid" Text='<% #DataBinder.Eval(Container.DataItem, "GLID") %>'
                            runat="server">
                        </asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="lblgouname" Text='<% #DataBinder.Eval(Container.DataItem, "GLName") %>'
                            runat="server">
                        </asp:Label>
                    </td>
                    <td>
                        <asp:ImageButton ID="imgbtnEdit" ImageUrl="" runat="server" OnClick="btnEditClick"
                            CommandName="Edit" />
                    </td>
                    <td>
                        <asp:ImageButton ID="imgbtnDelete" ImageUrl="" runat="server" OnClientClick="javascript:return confirm('Do you want to delete this?');" OnClick="btnDeleteClick" CommandName="Delete" />
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    <asp:Button ID="btnprev" Text="<<" Font-Bold="true" runat="server" OnClick="btnprev_Click" />
    <asp:Button ID="btnnext" Text=">>" Font-Bold="true" runat="server" OnClick="btnnext_Click" />
</asp:Content>

my problem is i click edit image in running time it refrrsh the page then it givepage load
txtGrouid but i want edit image selected rows glid=txtGrouid how i do it pls replay me

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.