So I have a gridview and a button that enables editing rows as following:

enter image description here

And once I want to edit the row, here is what happens: enter image description here

As you can see on the 2nd picture I get a white space where the other 2 buttons aren't supposed to appear when I'm editing another row, and I'd like the button from 2nd row to be aligned in center with these two above ( save and cancel ).

Here is code of grid (aspx page):

 <asp:GridView ID="gridKorisnici" AutoGenerateColumns="false" DataKeyNames="KupacID" AllowPaging="true" PageSize="20" runat="server" OnRowCommand="gridKorisnici_RowCommand" OnRowDataBound="gridKorisnici_RowDataBound" OnPageIndexChanging="gridKorisnici_PageIndexChanging" OnRowEditing="gridKorisnici_RowEditing" OnRowCancelingEdit="gridKorisnici_RowCancelingEdit" OnRowUpdating="gridKorisnici_RowUpdating">
        <Columns>
            <asp:BoundField ReadOnly="true" DataField="Ime" HeaderText="Ime"/>
            <asp:BoundField ReadOnly="true" DataField="Prezime" HeaderText="Prezime" />
            <asp:BoundField ReadOnly="true" DataField="Email" HeaderText="Email"/>

            <asp:TemplateField HeaderText="Iznos popusta(%)">
                <ItemTemplate>
                <asp:Label ID="Label3" runat="server" Text='<%# Eval("IznosPopusta") %>'></asp:Label>
                </ItemTemplate>
                 <EditItemTemplate>
                     <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("IznosPopusta") %>' ></asp:TextBox>
                 </EditItemTemplate>
            </asp:TemplateField>
                <asp:TemplateField HeaderText="Aktivan">

                 <ItemTemplate>
                     <asp:CheckBox ID="checkbox" runat="server" Enabled="false" Checked='<%# Eval("Status") %>'/>

                 </ItemTemplate>

                    <EditItemTemplate>
                  <asp:DropDownList ID="DropLista" DataSource='<%# Hegram_Projekat_Servis.ServisnaKlasa.PopulateCombo() %>' runat="server"></asp:DropDownList>
                    </EditItemTemplate>

            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="btnEdit" runat="server" Title="Napravi izmjene" CommandName="Edit"><img src="../images/1status.png" /></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>

                <asp:TemplateField>
                  <EditItemTemplate>
                <asp:LinkButton ID="btnUpdate" runat="server" title="Snimi" CommandName="Update"><img src="../images/Floppy-32.png" /></asp:LinkButton>
                <asp:LinkButton ID="btnCanel" runat="server" title="Odustani" CommandName="Cancel"><img src="../images/delete.png" /></asp:LinkButton>
                </EditItemTemplate>

                      </asp:TemplateField>
             <asp:TemplateField>
                <ItemTemplate>
                     <asp:LinkButton ID="btnHistorijaPristupa" title="Historija pristupa" runat="server" CommandName="HistorijaPristupaCommand" CommandArgument='<%# Eval("KupacID") %>'><img src="../images/1logovi.png" /></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
                </Columns>
    </asp:GridView>

And here is code behind for row editing event:

   protected void gridKorisnici_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gridKorisnici.EditIndex = e.NewEditIndex;
            BindGrid();

            LinkButton btnEdit = (LinkButton)gridKorisnici.Rows[e.NewEditIndex].FindControl("btnEdit");
// locating the edit button control inside of grid for specific row that is being edited
            btnEdit.Attributes.CssStyle.Add(HtmlTextWriterStyle.Display, "none");
// hiding it once the button is pressed and two others are shown ( save and cancel).
}

So my question is, is there any way I can remove the white space that I've marked with red circle on 2nd picture? Can someone help me out with this please?

Related posts

Recent Viewed