I have a gridview control with paging. Everything is good in IE.
But in Firefox and Chrome, the design breaks because of paging.
I attach the screenshots from IE and Firefox here:
In IE:
In Firefox:
Here is my grid view:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderWidth="0"
AllowPaging="true" ShowFooter="true" PageSize="3" Width="100%" OnPageIndexChanging="GridView1_PageIndexChanging"
OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating"
OnRowDeleting="GridView1_RowDeleting" OnRowCommand="GridView1_RowCommand" HorizontalAlign="Center">
<AlternatingRowStyle CssClass="gridAlternateRow" />
<FooterStyle CssClass="gridFooter" />
<PagerSettings Mode="NumericFirstLast" />
<PagerStyle HorizontalAlign="Center" CssClass="GridPager" VerticalAlign="Middle" Wrap="False" />
<HeaderStyle CssClass="GridHeader" />
<RowStyle CssClass="gridRow" />
<Columns>
<asp:TemplateField HeaderText="ID" Visible="false">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lbladd" runat="server"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="From Date" HeaderStyle-Width="10%">
<ItemTemplate>
<asp:Label ID="lblFromDate" runat="server" Text='<%#Eval("FromDate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox CssClass="myCalCss" ID="txtFromDate" runat="server" Text='<%#Eval("FromDate") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox CssClass="myCalCss" ID="txtAddFromDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqFromDate" ValidationGroup="ValgrpConUNIAnesthesiaFeeSchedule" ControlToValidate="txtAddFromDate" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
</FooterTemplate>
<HeaderStyle Width="15%"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="To Date" HeaderStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblToDate" runat="server" Text='<%#Eval("ToDate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox CssClass="myCalCss" ID="txtToDate" runat="server" Text='<%#Eval("ToDate") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox CssClass="myCalCss" ID="txtAddToDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqToDate" ValidationGroup="ValgrpConUNIAnesthesiaFeeSchedule" ControlToValidate="txtAddToDate" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
</FooterTemplate>
<HeaderStyle Width="15%"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Procedure Code" HeaderStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblProcedureCode" runat="server" Text='<%#Eval("ProcedureCode") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtProcedureCode" runat="server" Text='<%#Eval("ProcedureCode") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtAddProcedureCode" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqProcedureCode" ValidationGroup="ValgrpConUNIAnesthesiaFeeSchedule" ControlToValidate="txtAddProcedureCode" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
</FooterTemplate>
<HeaderStyle Width="15%"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="15%">
<ItemTemplate>
<span onclick="return confirm('Are you sure want to delete?')">
<asp:LinkButton CssClass="aDelete" ID="btnDelete" Text="Delete" runat="server" CommandName="Delete" />
</span>
<asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" CssClass="aEdit" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" CssClass="aUpdate" />
<asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" CssClass="aSave" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="btnInsertRecord" runat="server" Text="Add" ValidationGroup="ValgrpConUNIAnesthesiaFeeSchedule" CommandName="Insert" />
</FooterTemplate>
<HeaderStyle Width="15%"></HeaderStyle>
</asp:TemplateField>
</Columns>
</asp:GridView>
I take a look at Firebug and this is what I got in both IE and Firefox. Same HTML.
What am I missing?
Related
In my project I am working on showing Task Group and Task (i.e. Parent-child) in one screen with the ability to Add/Edit/Delete the parent (Task Group) record and also to Add/Edit/Delete associated Task. For this I am using nested Grid View (parent-child).
I am implementing the sample application mentioned in the below link to my ASP.NET web based project.
http://www.codeproject.com/Articles/20047/Editable-Nested-GridView-All-in-One
my .ASPX looks as mentioned below:
<%# Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Unicorn.Master" CodeBehind="TaskAndTaskGroup.aspx.cs" Inherits="Vipassi.Web.TaskGroup.TaskAndTaskGroup"%>
<asp:Content ID="Content1" ContentPlaceHolderID="phContent" runat="server">
<script language="javascript" type="text/javascript">
function expandcollapse(obj, row) {
var div = document.getElementById(obj);
var img = document.getElementById('img' + obj);
if (div.style.display == "none") {
div.style.display = "block";
if (row == 'alt') {
img.src = "../../Resources/images/minus.gif";
}
else {
img.src = "../../Resources/images/minus.gif";
}
img.alt = "Close to view other TaskGroups";
}
else {
div.style.display = "none";
if (row == 'alt') {
img.src = "../../Resources/images/plus.gif";
}
else {
img.src = "../../Resources/images/plus.gif";
}
img.alt = "Expand to show Tasks";
}
}
</script>
<div>
<asp:GridView ID="GridView1" AllowPaging="True" BackColor="#f1f1f1"
AutoGenerateColumns="false" DataSourceID="ObjectDataSource1" DataKeyNames="task_group_id"
ShowFooter="true" Font-Size="Small"
Font-Names="Verdana" runat="server" GridLines="None" OnRowDataBound="GridView1_RowDataBound"
OnRowCommand="GridView1_RowCommand" OnRowUpdating="GridView1_RowUpdating" BorderStyle=Outset
OnRowDeleting="GridView1_RowDeleting" OnRowDeleted="GridView1_RowDeleted"
OnRowUpdated="GridView1_RowUpdated" AllowSorting="true">
<RowStyle BackColor="Gainsboro" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#0083C1" ForeColor="White" />
<FooterStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="javascript:expandcollapse('div<%# Eval("task_group_id") %>', 'one');">
<img id="imgdiv<%# Eval("task_group_id") %>" alt="Click to show/hide Tasks for TaskGroup <%# Eval("task_group_id") %>" width="9px" border="0" src="../../Resources/images/plus.gif" />
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TaskGroup ID" SortExpression="task_group_id">
<ItemTemplate>
<asp:Label ID="lblTaskGroupID" Text='<%# Eval("task_group_id") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblTaskGroupID" Text='<%# Eval("task_group_id") %>' runat="server"></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTaskGroupID" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Task Group" SortExpression="task_group">
<ItemTemplate><%# Eval("task_group") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTaskGroup" Text='<%# Eval("task_group") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTaskGroup" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fiscal Year" SortExpression="Fiscal_Year">
<ItemTemplate><%# Eval("Fiscal_Year") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtFiscalYear" Text='<%# Eval("Fiscal_Year") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtFiscalYear" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Is Active" SortExpression="Active_Flag">
<ItemTemplate><%# Eval("Active_Flag")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtActiveFlag" Text='<%# Eval("Active_Flag") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtActiveFlag" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteTaskGroup" CommandName="Delete" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddTaskGroup" CommandName="AddTaskGroup" runat="server">Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# Eval("task_group_id") %>" style="display: none; position: relative; left: 15px; overflow: auto; width: 97%">
<asp:GridView ID="GridView2" AllowPaging="True" AllowSorting="true" BackColor="White" Width="100%" Font-Size="X-Small"
AutoGenerateColumns="false" Font-Names="Verdana" runat="server" DataKeyNames="task_group_id" ShowFooter="true"
OnPageIndexChanging="GridView2_PageIndexChanging" OnRowUpdating="GridView2_RowUpdating"
OnRowCommand="GridView2_RowCommand" OnRowEditing="GridView2_RowEditing" GridLines="None"
OnRowUpdated="GridView2_RowUpdated" OnRowCancelingEdit="GridView2_CancelingEdit" OnRowDataBound="GridView2_RowDataBound"
OnRowDeleting="GridView2_RowDeleting" OnRowDeleted="GridView2_RowDeleted" OnSorting="GridView2_Sorting"
BorderStyle="Double" BorderColor="#0083C1">
<RowStyle BackColor="Gainsboro" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#0083C1" ForeColor="White" />
<FooterStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Task ID" SortExpression="task_id">
<ItemTemplate>
<asp:Label ID="lblTaskID" Text='<%# Eval("task_id") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblTaskID" Text='<%# Eval("task_id") %>' runat="server"></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Task" SortExpression="task_name">
<ItemTemplate><%# Eval("task_name")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTask" Text='<%# Eval("task_name")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTask" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fiscal Year" SortExpression="fiscal_year">
<ItemTemplate><%# Eval("fiscal_year")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTaskFiscalYear" Text='<%# Eval("fiscal_year")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTaskFiscalYear" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Is Active" SortExpression="Active_Flag">
<ItemTemplate><%# Eval("Active_Flag")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTaskActiveFlag" Text='<%# Eval("Active_Flag")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTaskActiveFlag" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteTaskGroup" CommandName="Delete" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddTask" CommandName="AddTask" runat="server">Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource SortParameterName="sortExpression" EnablePaging="true" ID="ObjectDataSource1"
MaximumRowsParameterName="maxRecords" TypeName="Vipassi.BLL.Classes.TaskGroup.TaskGroupBLL"
SelectMethod="ListforTaskGroup" SelectCountMethod="ListCountforTaskGroup" StartRowIndexParameterName="startIndex"
runat="server">
<SelectParameters>
<asp:SessionParameter SessionField="orgId" Name="orgId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
Option 1:
You can disable the VIEWSTATE of ASPX page /User Control :
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="~/TaskAndTaskGroup.aspx.cs" Inherits="Vipassi.Web.TaskGroup.TaskAndTaskGroup" EnableViewState="false"%>
Option 2:
You can also change your source code to make sure the controls added during a post-back must match the type and position of the controls added during the initial request.
Hope this will help you.
This has driven me crazy a few times in the past but I've always fudged it and moved on. Today I want to try and fix it!
I quite frequently create a GridView to display data and a FormView directly beneath in Insert mode with controls in the InsertItemTemplate corresponding to the columns in the GridView, so that it looks like the FormView is just an empty row of the GridView awaiting new data entry. This works great.
The problem is that I can never get the widths of the 'columns' (really just textboxes) in the FormView to correspond to the widths of the columns in the GridView above.
In the example below, as you can see, both the GridView and FormView have a width of 100% and, sure enough, when the page is rendered they're both exactly the same width (I gave the FormView a border briefly to check). However, even though the widths of the textboxes in the FormView are identical to the widths of the columns in the GridView, they don't display that way. The textboxes are slightly wider, and by the time you get to the right-most column the cumulative effect means that the alignment is way out.
I'm guessing the problem is something to do with border widths or some other hidden element which is being rendered, but I can't figure it out. I have to say, the amount by which the alignment is out seems more than the couple of pixels a border would affect things.
<asp:GridView ID="gvTPR" runat="server" DataSourceID="SQLTPR" AutoGenerateColumns="false" DataMember="DefaultView" DataKeyNames="TPRID" Width="100%" >
<RowStyle HorizontalAlign="Center" />
<EditRowStyle BackColor="#ccffff" />
<HeaderStyle BackColor="#013b82" ForeColor="White" />
<Columns>
<asp:BoundField DataField="TPREnteredAt" HeaderText="Entered At" ReadOnly="True" SortExpression="TPREnteredAt" ItemStyle-Width="24%" ControlStyle-Width="90%" />
<asp:BoundField DataField="TPRTemp" HeaderText="Temp" ReadOnly="True" SortExpression="TPRTemp" ItemStyle-Width="12%" ControlStyle-Width="90%"/>
<asp:BoundField DataField="TPRPulse" HeaderText="Pulse" ReadOnly="True" SortExpression="TPRPulse" ItemStyle-Width="12%" ControlStyle-Width="90%"/>
<asp:BoundField DataField="TPRRespiration" HeaderText="Respiration" ReadOnly="True" SortExpression="TPRRespiration" ItemStyle-Width="12%" ControlStyle-Width="90%"/>
<asp:BoundField DataField="TPRPCV" HeaderText="PCV" ItemStyle-Width="12%" ControlStyle-Width="90%"/>
<asp:BoundField DataField="TPRTP" HeaderText="TP" ItemStyle-Width="12%" ControlStyle-Width="90%" />
<asp:CommandField ButtonType="Button" InsertVisible="False" ShowEditButton="True" ItemStyle-Width="16%" UpdateText="Save" ControlStyle-Width="60px" />
</Columns>
<EmptyDataTemplate>
No TPR records exist
</EmptyDataTemplate>
</asp:GridView>
<asp:FormView ID="fvTPR" runat="server" DataSourceID="SQLTPR" DefaultMode="Insert" Width="100%" >
<InsertItemTemplate>
<asp:textbox ID="lblEnteredAt" runat="server" Text="Will be added automatically" Width="24%" />
<asp:TextBox ID="txtTemp" runat="server" Text='<%# Bind("TPRTemp")%>' Width="12%" />
<asp:TextBox ID="txtPulse" runat="server" Text='<%# Bind("TPRPulse")%>' Width="12%" />
<asp:TextBox ID="txtRespiration" runat="server" Text='<%# Bind("TPRRespiration")%>' Width="12%" />
<asp:TextBox ID="txtPCV" runat="server" Text='<%# Bind("TPRPCV")%>' Width="12%" />
<asp:TextBox ID="txtTP" runat="server" Text='<%# Bind("TPRTP")%>' Width="12%" />
<asp:Button ID="btnAddTPR" runat="server" Text="Save" Width="5%" />
</InsertItemTemplate>
</asp:FormView>
This renders like this:
How about using GridView footer for add funcionality? This way you will have all columns in same table and you'l get around your positioning problems.
Here is an example of how your gridview should look like:
<asp:GridView ID="gvTPR" runat="server" DataSourceID="SQLTPR" AutoGenerateColumns="False" ShowFooter="True" DataKeyNames="TPRID" Width="100%" EnableModelValidation="True">
<RowStyle HorizontalAlign="Center" />
<EditRowStyle BackColor="#ccffff" />
<HeaderStyle BackColor="#013b82" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="Entered At" SortExpression="TPREnteredAt">
<EditItemTemplate>
<asp:TextBox ID="lblEnteredAt" runat="server" Text='<%# Eval("TPREnteredAt") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("TPREnteredAt") %>'></asp:Label>
</ItemTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="24%" />
<FooterTemplate>
<asp:TextBox ID="lblEnteredAt" runat="server" Text="Will be added automatically" Width="24%" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Temp" SortExpression="TPRTemp">
<EditItemTemplate>
<asp:TextBox ID="txtTemp" runat="server" Text='<%# Eval("TPRTemp") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("TPRTemp") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTemp" runat="server" Text='<%# Bind("TPRTemp")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Pulse" SortExpression="TPRPulse">
<EditItemTemplate>
<asp:TextBox ID="txtPulse" runat="server" Text='<%# Eval("TPRPulse") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("TPRPulse") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPulse" runat="server" Text='<%# Bind("TPRPulse")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Respiration" SortExpression="TPRRespiration">
<EditItemTemplate>
<asp:TextBox ID="txtRespiration" runat="server" Text='<%# Eval("TPRRespiration") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("TPRRespiration") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtRespiration" runat="server" Text='<%# Bind("TPRRespiration")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="PCV">
<EditItemTemplate>
<asp:TextBox ID="txtPCV" runat="server" Text='<%# Bind("TPRPCV") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("TPRPCV") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPCV" runat="server" Text='<%# Bind("TPRPCV")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="TP">
<EditItemTemplate>
<asp:TextBox ID="txtTP" runat="server" Text='<%# Bind("TPRTP") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("TPRTP") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTP" runat="server" Text='<%# Bind("TPRTP")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="lnkbtnEdit" runat="Server" Text="Edit" CommandName="Edit"
CausesValidation="false"></asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="lnkbtnUpdate" runat="Server" Text="Save" CommandName="Update"
CausesValidation="true"></asp:Button><br />
<asp:LinkButton ID="lnkbtnCancel" runat="Server" Text="Cancel" CommandName="Cancel"
CausesValidation="false"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="lnkbtnInsert" runat="Server" Text="Save" CommandName="Insert"
CausesValidation="true"></asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No TPR records exist
</EmptyDataTemplate>
</asp:GridView>
Hope this helps!
Regards,
Uros
I am having a gridview and I have showeditbutton property false, showdeletebutton property true.Edit is a link button and a row command event is fired on clicking it.
Now,my problem is that in gridview, when I click on edit link, delete link gets disappear.
I have written
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" PageSize="5" OnRowCommand="gv_RowCommand"
AllowPaging="true" DataKeyNames="ID" CssClass="mGrid" BackColor="White" BorderColor="Silver" BorderStyle="Double"
BorderWidth="1px" CellPadding="4" >
<RowStyle BackColor="White" Width="150%" ForeColor="#003399" />
<Columns>
<asp:TemplateField HeaderText="ID" Visible="false" >
<ItemTemplate>
<asp:Label ID="lblID" Text='<%#Bind("ID") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Version">
<ItemTemplate>
<asp:Label ID="lblversion" Text='<%#Bind("version") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image ID">
<ItemTemplate>
<asp:Label ID="lblimageid" runat="server" Text='<%#Bind("image_id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Getty ID">
<ItemTemplate>
<asp:Label ID="lblgettyid" runat="server" Text='<%#Bind("getty_id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Pool Letter">
<ItemTemplate>
<asp:Label ID="lblpoolletter" runat="server" Text='<%#Bind("pool_letter") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="To Use">
<ItemTemplate>
<asp:Label ID="lbltouse" runat="server" Text='<%#Bind("to_use") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Clue">
<ItemTemplate>
<asp:Label ID="lblclue" runat="server" Text='<%#Bind("clue") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Range">
<ItemTemplate>
<asp:Label ID="lblrange" runat="server" Text='<%#Bind("range") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="last_updated">
<ItemTemplate>
<asp:Label ID="lbllastupdated" runat="server" Text='<%#Bind("last_updated") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Text='<%#Bind("status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="First">
<ItemTemplate>
<asp:Label ID="lblfirst" runat="server" Text='<%#Bind("first") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Middle">
<ItemTemplate>
<asp:Label ID="lblmiddle" runat="server" Text='<%#Bind("middle") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last">
<ItemTemplate>
<asp:Label ID="lbllast" runat="server" Text='<%#Bind("last") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate>
<asp:LinkButton ID="lnkbtnedit" Text="Edit" style="color:#003399;" CommandName="Edit" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="true" CausesValidation="false" />
</Columns>
<PagerStyle BackColor="#006699" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="#CCFFFF" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
can I get any help?
You can include the delete button in your ItemTemplate:
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkbtnedit" Text="Edit" style="color:#003399;" CommandName="Edit" runat="server"></asp:LinkButton>
<asp:LinkButton ID="lnkbtndelete" Text="Delete" style="color:#003399;" CommandName="Delete" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
And then just remove the CommandField.
Replace your below code
<asp:TemplateField >
<ItemTemplate>
<asp:LinkButton ID="lnkbtnedit" Text="Edit" style="color:#003399;"
CommandName="Edit" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="true" CausesValidation="false" />
with this code.
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top"
HeaderStyle-Width="10%">
<ItemTemplate>
<asp:LinkButton ID="lnkbtnedit" runat="server" CommandName="Edit" Text="Edit" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="btndelete" runat="server" CommandName="Delete" Text="Delete"
CommandArgument="<%#((GridViewRow)Container).RowIndex%>"/>
</EditItemTemplate>
</asp:TemplateField>
I am developing a ASP.NET web application. One of my from perform very slow in client machine. Where I use GridView which include some function and some control on there like combo-box input box, each control have some function and calculation on there leave.
Please suggest me how can I improve this?
Page on content.
- GridView
1. Combobox with jquery datafiltering
2. Inputbox with data check function
3. More function of grid like update,add, new, delete.
I am also use Viewsate on this page.
<%# Page Title="" Language="C#" MasterPageFile="~/UI/Healthcare.Master" AutoEventWireup="true" CodeBehind="frmStockIn.aspx.cs" Inherits="Com.Codespecies.Healthcare.UI.Pharmacy.frmStockIn" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder_header" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
...........
....
....
<div class="box_bg" style="height: auto; width: 1020px; border: 0px solid; border-color: #0167AA; margin:5px 0px 0px 0px; float:left;">
<div style=" min-height:30px; width: 1005px; padding: 0px 0px 0px 2px;">
<div style="min-height: 30px; width:auto; width:300px; float: left; font-weight: bold;">
Drugs Details
</div>
<div style="min-height: 30px; width: 600px; float: left;">
<div id="msg" style="height:auto; float:left;">
<asp:Label ID="lblMsg" runat="server" Text=" "></asp:Label>
</div>
<div id="ajaxLoader" style=" display:none; margin:2px 0px 0px 0px; float:left;">
<img height="20px" width="20px" src="../../image/ajax-loading/ajax-loading-2.gif" alt="loader" border="0" style=""/>
</div>
</div>
</div>
<div style=" width: auto; padding: 0px 0px 5px 0px;">
<asp:GridView ID="gvStockIn" runat="server" AllowPaging="True" Width="1020px"
AlternatingRowStyle-HorizontalAlign="Left" AlternatingRowStyle-VerticalAlign="Middle"
AutoGenerateColumns="False" BorderStyle="None" DataKeyNames="ID"
Font-Names="Calibri" Font-Size="Small" ForeColor="#333333" GridLines="None"
PageSize="100" ShowFooter="True" ShowHeaderWhenEmpty="True"
onrowcancelingedit="gvStockIn_RowCancelingEdit" onrowcommand="gvStockIn_RowCommand"
onrowdeleting="gvStockIn_RowDeleting" onrowediting="gvStockIn_RowEditing"
onrowupdating="gvStockIn_RowUpdating" onrowdatabound="gvStockIn_RowDataBound"
AllowSorting="True" TabIndex="5">
<AlternatingRowStyle BackColor="#DCEEFC" Font-Names="Calibri" HorizontalAlign="Left" VerticalAlign="Middle" />
<Columns>
<asp:TemplateField HeaderText="SL" SortExpression="ID">
<ItemStyle Width="30px" />
<HeaderStyle Width="30px" />
<FooterStyle Width="30px" />
<EditItemTemplate>
<asp:Label ID="lblSerialNo" runat="server" Text='<%# Eval("ID") %>' Width="30px"></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="lblNewSerialNo" runat="server" Width="30px">NA</asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblSerialNo" runat="server" Text='<%# Bind("ID") %>' Width="30px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Drug" >
<ItemStyle Width="170px" />
<HeaderStyle Width="170px" />
<FooterStyle Width="170px" />
<EditItemTemplate>
<asp:Label ID="lblDrug" runat="server" Text='<%# Bind("DRUG_NAME") %>' Width="170px"></asp:Label>
<%--<asp:TextBox ID="txtDrug" runat="server" CssClass="Drug" Text='<%# Eval("DRUG_NAME") %>' Width="100px"></asp:TextBox>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList CssClass="fire_selected_change_event combobox combobox1" ID="ddlNewDrug" runat="server" onselectedindexchanged="ddlNewDrug_SelectedIndexChanged">
</asp:DropDownList>
<%--<asp:TextBox ID="txtNewDrug" runat="server" CssClass="Drug" Width="100px"></asp:TextBox>--%>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblDrug" runat="server" Text='<%# Bind("DRUG_NAME") %>' Width="170px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Presentation">
<ItemStyle Width="130px" />
<HeaderStyle Width="130px" />
<FooterStyle Width="130px" CssClass="drug_list1"/>
<EditItemTemplate>
<asp:Label ID="lblPresentation" runat="server" Text='<%# Bind("PRESENTATION_NAME") %>' Width="130px"></asp:Label>
<%--<asp:TextBox ID="txtPresentation" runat="server" CssClass="Presentation" Text='<%# Eval("PRESENTATION_NAME") %>' Width="110px"></asp:TextBox>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList CssClass="fire_selected_change_event combobox combobox1" ID="ddlNewPresentation" runat="server" AutoPostBack="True" onselectedindexchanged="ddlNewPresentation_SelectedIndexChanged">
</asp:DropDownList>
<%--<asp:TextBox ID="txtNewPresentation" runat="server" CssClass="Presentation" Width="110px"></asp:TextBox>--%>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblPresentation" runat="server" Text='<%# Bind("PRESENTATION_NAME") %>' Width="130px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Unit Strength">
<ItemStyle Width="130px" />
<HeaderStyle Width="130px" />
<FooterStyle Width="130px" CssClass="drug_list1"/>
<EditItemTemplate>
<asp:Label ID="lblUnitStrength" runat="server" Text='<%# Bind("DRUG_UNIT_STRENGTH") %>' Width="110px"></asp:Label>
<%--<asp:TextBox ID="txtUnitStrength" runat="server" CssClass="UnitStrength" Text='<%# Eval("DRUG_UNIT_STRENGTH") %>' Width="110px"></asp:TextBox>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList CssClass="fire_selected_change_event combobox combobox1" ID="ddlNewUnitStrength" runat="server" AutoPostBack="True" onselectedindexchanged="ddlNewUnitStrength_SelectedIndexChanged">
</asp:DropDownList>
<%--<asp:TextBox ID="txtNewUnitStrength" runat="server" CssClass="UnitStrength" Width="110px"></asp:TextBox>--%>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblUnitStrength" runat="server" Text='<%# Bind("DRUG_UNIT_STRENGTH") %>' Width="110px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mfg Date">
<ItemStyle Width="65px" />
<HeaderStyle Width="65px" />
<FooterStyle Width="65px" />
<EditItemTemplate>
<asp:TextBox ID="txtManufacturerDate" runat="server" CssClass="date_property" Text='<%# Eval("DRUG_MANUFACTURER_DATE", "{0:dd/MM/yyyy}") %>' Height="25px" Width="65px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewManufacturerDate" runat="server" CssClass="date_property" Height="25px" Width="65px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblManufacturerDate" runat="server" Text='<%# Bind("DRUG_MANUFACTURER_DATE", "{0:dd/MM/yyyy}") %>' Height="25px" Width="65px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Exp. Date">
<ItemStyle Width="65px" />
<HeaderStyle Width="65px" />
<FooterStyle Width="65px" />
<EditItemTemplate>
<asp:TextBox ID="txtExpireDate" runat="server" CssClass="date_property" Text='<%# Eval("DRUG_EXPIRE_DATE", "{0:dd/MM/yyyy}") %>' Height="25px" Width="65px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewExpireDate" runat="server" CssClass="date_property" Height="25px" Width="65px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblExpireDate" runat="server" Text='<%# Bind("DRUG_EXPIRE_DATE", "{0:dd/MM/yyyy}") %>' Height="25px" Width="65px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Qty">
<ItemStyle Width="40px" HorizontalAlign="Right" />
<HeaderStyle Width="40px" HorizontalAlign="Right" />
<FooterStyle Width="40px" HorizontalAlign="Right" />
<EditItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server" CssClass="check_decimal Quantity" Text='<%# Eval("QUANTITY") %>' Height="25px" Width="40px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewQuantity" runat="server" CssClass="check_decimal Quantity" Height="25px" Width="40px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server" Text='<%# Bind("QUANTITY") %>' Height="25px" Width="40px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Cost Price">
<ItemStyle Width="70px" HorizontalAlign="Right"/>
<HeaderStyle Width="70px" HorizontalAlign="Right"/>
<FooterStyle Width="70px" HorizontalAlign="Right"/>
<EditItemTemplate>
<asp:TextBox ID="txtCostPrice" runat="server" CssClass="check_decimal CostPrice" Text='<%# Eval("COST_PRICE") %>' ontextchanged="txtCostPrice_TextChanged" AutoPostBack="true" Height="25px" Width="60px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewCostPrice" runat="server" CssClass="check_decimal CostPrice" ontextchanged="txtNewCostPrice_TextChanged" AutoPostBack="true" Height="25px" Width="60px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblCostPrice" runat="server" Text='<%# Bind("COST_PRICE") %>' Height="25px" Width="60px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sale Price">
<ItemStyle Width="70px" HorizontalAlign="Right"/>
<HeaderStyle Width="70px" HorizontalAlign="Right"/>
<FooterStyle Width="70px" HorizontalAlign="Right"/>
<EditItemTemplate>
<asp:TextBox ID="txtSellPrice" runat="server" CssClass="check_decimal SellPrice" Text='<%# Eval("SELL_PRICE") %>' Height="25px" Width="60px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewSellPrice" runat="server" CssClass="check_decimal SellPrice" Height="25px" Width="60px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblSellPrice" runat="server" Text='<%# Bind("SELL_PRICE") %>' Height="25px" Width="60px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Discount">
<ItemStyle Width="60px" HorizontalAlign="Right"/>
<HeaderStyle Width="60px" HorizontalAlign="Right"/>
<FooterStyle Width="60px" HorizontalAlign="Right"/>
<EditItemTemplate>
<asp:TextBox ID="txtDiscount" runat="server" CssClass="check_decimal percentage" Text='<%# Eval("DISCOUNT") %>' Height="25px" Width="60px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewDiscount" runat="server" CssClass="check_decimal percentage" Height="25px" Width="60px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblDiscount" runat="server" Text='<%# Bind("DISCOUNT") %>' Height="25px" Width="60px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sub Total">
<ItemStyle Width="70px" HorizontalAlign="Right"/>
<HeaderStyle Width="70px" HorizontalAlign="Right"/>
<FooterStyle Width="70px" HorizontalAlign="Right"/>
<EditItemTemplate>
<asp:TextBox ID="txtSubTotal" runat="server" CssClass="check_decimal" Text='<%# Eval("SUB_TOTAL_AMOUNT") %>' ontextchanged="txtSubTotal_TextChanged" AutoPostBack="true" Height="25px" Width="70px"></asp:TextBox>
<%--<asp:Label ID="lblSubTotal" runat="server" Text='<%# Eval("SUB_TOTAL_AMOUNT") %>' Height="25px" Width="80px"></asp:Label>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewSubTotal" runat="server" CssClass="check_decimal" Text='' ontextchanged="txtNewSubTotal_TextChanged" AutoPostBack="true" Height="25px" Width="70px"></asp:TextBox>
<%--<asp:Label ID="lblSubTotal" runat="server" Text='' Height="25px" Width="80px"></asp:Label>--%>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblSubTotal" runat="server" Text='<%# Bind("SUB_TOTAL_AMOUNT") %>' Height="25px" Width="70px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" ShowHeader="False">
<ItemStyle Width="100px" HorizontalAlign="Center"/>
<HeaderStyle Width="100px" HorizontalAlign="Center"/>
<FooterStyle Width="100px" HorizontalAlign="Center"/>
<EditItemTemplate>
<asp:ImageButton ID="lnkUpdate" ToolTip="Update" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/update.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Update" ></asp:ImageButton>
<asp:ImageButton ID="lnkCancel" ToolTip="Cancel" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/cancel.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Cancel" ></asp:ImageButton>
<%-- <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="False" OnClientClick="load_ajax_drugs_details();" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="False" OnClientClick="load_ajax_drugs_details();" CommandName="Cancel" Text="Cancel"></asp:LinkButton>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:ImageButton ID="lnkNew" ToolTip="New" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/add.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="New" ></asp:ImageButton>
<asp:ImageButton ID="lnkRefresh" ToolTip="Refresh" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/refresh.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Refresh" ></asp:ImageButton>
</FooterTemplate>
<ItemTemplate>
<asp:ImageButton ID="lnkEdit" ToolTip="Edit" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/edit.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Edit" ></asp:ImageButton>
<%--<asp:LinkButton ID="lnkEdit" ToolTip="Edit" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/edit.png" Height="10px" Width="15px" CausesValidation="False" CommandArgument="" CommandName="Edit" Text="Edit"></asp:LinkButton>--%>
<asp:ImageButton ID="lnkDelete" ToolTip="Delete" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/delete.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Delete" ></asp:ImageButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#507CD1" ForeColor="White" HorizontalAlign="Left" VerticalAlign="Middle" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Right" VerticalAlign="Middle" />
<RowStyle Font-Names="Calibri" />
<FooterStyle CssClass="drug_list"></FooterStyle>
</asp:GridView>
</div>
.....
.....
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
}
There is a lot of reasons for this issue.As far as i under stood from your question I will suggest some places where you need to take a look at.
1)Check how much data you retrieves from database in order to show the gridview primarily.
2)adding the above controls to the gridview won't make it perform badly.But the calculations you where talking about may be a cause.Take a deep look at the code ,check whether there is any long running loops or some thing else is there.
3)if the first two is not helping you make a profiling.For your problem you just need a trial version of ants performance profiler.
After installing the profile find out which database call or .net function is taking more time to execute then debug it.
I have a grid to update the employee's confirmation. I need to change the data from grid using edit and delete link. I have trouble to create this grid. Because gridview all textbox enable always.Textbox only enable when am click the edit button.
This is my partial code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
Width="100%" AutoGenerateColumns="False" CssClass="GridViewStyle" GridLines="None"
ShowHeaderWhenEmpty="True" EmptyDataText="No Data Found"
onpageindexchanging="GridView1_PageIndexChanging"
AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating" >
<Columns>
<asp:TemplateField HeaderText="EMP ID">
<ItemTemplate>
<asp:TextBox ID="lblempId" runat="server" Text='<%#Bind("fldemp_id") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EMPLOYEE NAME">
<ItemTemplate>
<asp:TextBox ID="lblusername" runat="server" Text='<%#Bind("fldempname") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="JOINDATE">
<ItemTemplate>
<asp:TextBox ID="lbljoin" runat="server" Text='<%#Bind("fldjoindate") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CONFIRMATION DATE">
<ItemTemplate>
<asp:TextBox ID="lblconfirm" runat="server" Text='<%#Bind("fldconfirmdate") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="STATUS">
<ItemTemplate>
<asp:TextBox ID="lblStatus" runat="server" Text='<%#Bind("fldstatus") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CONFIRMATION STATUS">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Eval("fldcon_status") %>' >
<asp:ListItem>Confirmed</asp:ListItem>
<asp:ListItem>Not-Confirmed</asp:ListItem>
<asp:ListItem>Extended</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderImageUrl="~/images/edit.png">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/edit.png" CommandName="edi"
CommandArgument='<%#Bind("fldemp_id") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderImageUrl="~/images/Delete.png">
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/Delete.png"
CommandName="del" CommandArgument='<%#Bind("fldemp_id") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="RowStyle" />
<EmptyDataRowStyle CssClass="EmptyRowStyle" />
<PagerStyle CssClass="PagerStyle" />
<SelectedRowStyle CssClass="SelectedRowStyle" />
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Left" />
<EditRowStyle CssClass="EditRowStyle" />
<AlternatingRowStyle CssClass="AltRowStyle" />
</asp:GridView>
If you're asking how to disable editing in the grid until someone hits an Edit button, simply set Enabled property to False on the grid until your button is pressed.