How to adjust footer template horizontal align? - asp.net

I would like to adjust footer template horizontal align as left in grid but, it's not working any one can explain please. this is my code
<asp:GridView ID="Grd_View" ShowFooter="True" runat="server" OnRowEditing="Grd_View_RowEditing" AutoGenerateColumns="False"
DataKeyNames="CustomerCode" CellPadding="4" OnRowCommand="Grd_View_RowCommand" GridLines="None" ShowHeader="True"
AllowPaging="True" AllowSorting="True" CssClass="style2" ForeColor="#333333" OnRowDataBound="Grd_View_RowDataBound"
OnRowDeleting="Grd_View_RowDeleting" >
<FooterStyle BackColor="#555555" ForeColor="White" HorizontalAlign="Center" Font-Bold="True" />
<Columns>
<asp:BoundField DataField="CustomerCode" HeaderText="Customer Code" InsertVisible="False"
ReadOnly="True" SortExpression="CustomerCode" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="CustomerName" HeaderText="Customer Name" SortExpression="CustomerName" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="TellNo" HeaderText="Tell No" SortExpression="TellNo" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="FaxNo" HeaderText="Fax No" SortExpression="FaxNo" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="PIC" HeaderText="Person in Contact" SortExpression="PIC" ItemStyle-HorizontalAlign="Center" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btnEdit" runat="server" CommandArgument='<%#Eval("CustomerCode")%>' CommandName="Edit" Text="Edit">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btnDelete" runat="server" CommandArgument='<%#Eval("CustomerCode")%>' CommandName="Delete" Text="Delete">
</asp:LinkButton>
</ItemTemplate>
<FooterTemplate> <asp:LinkButton ForeColor="white" ID="btnNew" runat="server" CommandArgument='<%#Eval("CustomerCode")%>' CommandName="New" Text="New">
</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#777777" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#555555" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>

Try using the below:
<FooterTemplate>
<asp:LinkButton ForeColor="white" ID="btnNew" runat="server" CommandName="New" Text="New">
</asp:LinkButton>
</FooterTemplate>
<FooterStyle HorizontalAlign="Left" />

The Reason your footer template will always be in right is because you are creating it as the last column in the GridView along with the Delete column.
To solve this you need to create the footer template in the first column or I'll recommend just putting the footer template inside with edit template field in the first column and the delete template field in the second column.

Related

ASP.NET GridView Needs two Different Action Buttons

I've got a GridView that I'd like to have two buttons with two different actions. I had tried making both of them select buttons, which would be optimal, but I can't get ASP.NET to tell me which of the two buttons triggered the event. It'll tell you the row index, but not the column from what I see.
I changed one of my buttons to an edit button so that it then calls a different method, but then it puts the row into edit mode. I do not see a way to cancel the edit, AND it is mis-using the intended use of the code.
The buttons are in the first and last columns of the gv.
<asp:GridView ID="gvMedList" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="dsMedList" GridLines="Vertical" OnSelectedIndexChanged="gvMedAction" OnDataBound="gvMedList_DataBound" OnRowEditing="gvRefillButton">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:CommandField ButtonType="Button" SelectText=" -STOP- " ShowSelectButton="True" ShowCancelButton="False" />
<asp:CheckBoxField DataField="Active_Med" HeaderText="Active" SortExpression="Active_Med" >
<HeaderStyle Width="50px" />
<ItemStyle HorizontalAlign="Center" />
</asp:CheckBoxField>
<asp:BoundField DataField="Medication_List_ID" HeaderText="Medication_List_ID" InsertVisible="False" ReadOnly="True" SortExpression="Medication_List_ID" >
<HeaderStyle Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="Label_Name" HeaderText="Medication" SortExpression="Label_Name" >
<HeaderStyle Width="150px" />
</asp:BoundField>
<asp:BoundField DataField="Med_Form" HeaderText="Form" SortExpression="Med_Form" >
<HeaderStyle Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="dose" HeaderText="Dose" SortExpression="dose" >
<HeaderStyle Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="dose_unit" HeaderText="Unit" SortExpression="dose_unit" >
<HeaderStyle Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="Med_Amt" HeaderText="Med_Amt" SortExpression="Med_Amt" Visible="False" />
<asp:BoundField DataField="Amount_Unit" HeaderText="Amount_Unit" SortExpression="Amount_Unit" Visible="False" />
<asp:BoundField DataField="Med_Sched_Label" HeaderText="Frequency" SortExpression="Med_Sched_Label" >
<HeaderStyle Width="150px" />
</asp:BoundField>
<asp:BoundField DataField="Med_Dispense" HeaderText="Dispense" SortExpression="Med_Dispense" >
<HeaderStyle Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="Dispense_Unit" HeaderText="Unit" SortExpression="Dispense_Unit" ShowHeader="False" >
<ItemStyle Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="Med_Refill" HeaderText="Med_Refill" SortExpression="Med_Refill" Visible="False" />
<asp:BoundField DataField="Comments" HeaderText="Comments" SortExpression="Comments" />
<asp:CommandField ButtonType="Button" EditText="-REFILL-" ShowCancelButton="False" ShowEditButton="True" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#27627E" Font-Bold="True" ForeColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" Height="20px" HorizontalAlign="Center" VerticalAlign="Middle" Width="125px" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
Use the CommandName property
Front-End
<asp:GridView ID="gvMedList" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="dsMedList" GridLines="Vertical" OnSelectedIndexChanged="gvMedAction" OnDataBound="gvMedList_DataBound" OnRowEditing="gvRefillButton" OnRowCommand="gvMedList_RowCommand">
<Columns>
<asp:TemplateField HeaderText="ColumnName">
<ItemTemplate>
<asp:Button ID="btnDoSomething" runat="server" CommandName="DoSomething" Text="Do Something" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="AnotherColumn">
<ItemTemplate>
<asp:ImageButton ID="btnImageSomething" runat="server" CommandName="DoSomethingElse" ImageUrl="~/images/yes.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code-Behind (assumed C#...if you need VB let me know)
protected void gvMedList_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DoSomething")
{
// code to execute
}
if (e.CommandName == "DoSomethingElse")
{
// code to execute
}
}

EmptyDataTemplate Does not show when Empty

I have a gridview that has a EmptyDataTemplate, but it does not show when there is no data.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" DataKeyNames="TransID"
Font-Size="Small" GridLines="Vertical" HorizontalAlign="Center" PageSize="50"
AutoGenerateDeleteButton="True" AllowSorting="True" >
<PagerSettings FirstPageText="First" LastPageText="Last" Mode="NextPreviousFirstLast"
NextPageText="Next" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="TransID" HeaderText="Transaction ID" InsertVisible="False"
ReadOnly="True" SortExpression="TransID">
<HeaderStyle Font-Underline="False" />
</asp:BoundField>
<asp:BoundField DataField="LicNumFrom" HeaderText="License Number From" SortExpression="LicNumFrom" />
<asp:BoundField DataField="LicNameFrom" HeaderText="Name From" SortExpression="LicNameFrom" />
<asp:BoundField DataField="LicNumTo" HeaderText="License Number To" SortExpression="LicNumTo" />
<asp:BoundField DataField="LicNameTo" HeaderText="Name To" SortExpression="LicNameTo" />
<asp:BoundField DataField="DateOfDelivery" HeaderText="Date Of Delivery" SortExpression="DateOfDelivery"
DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#2D5278" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
<EmptyDataTemplate>
<div>
No Data Available
</div>
</EmptyDataTemplate>
</asp:GridView>
All it shows is a little square. I've tried putting a Label in the EmptyDataTemplate, but it doesn't work either.
You should check the CSS style of EmptyDataTemplate. It looks like you are getting it in a square box but texts are same as your background color and so they are lost in the background. You are getting that square box because you are applying 1px black border to your GridView which also gets applied to EmptyDataTemplate by default.
Try to apply EmptyDataRowStyle-ForeColor="#000" attribute to your GridView with any color which is not same as GridView background color and check the result.

Error when trying to retain updatepanel values

I'm having a problem with a couple of dropdown boxes in my gridview losing their values upon postback.
Everything is within an update panel so I have tried to include into my code but this just throws an exception. See the below code, I have a child gridview within a larger one:
I am receiving the following exception when I go to load the gridview: A control with ID 'DropDownNote' could not be found for the trigger in UpdatePanel 'UpdateGV'.
I followed what was in this post: Control in UpdatePanel loses value
But now I'm getting the above exception, what am I missing here? Will solving this problem retain the values of the dropdowns after the postback?
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<asp:GridView ID="GVAccounts" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333"
GridLines="Horizontal"
style="position: relative; margin-top: 10px">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="branch" HeaderText="Branch"
SortExpression="branch" />
<asp:BoundField DataField="no" HeaderText="Account"
SortExpression="account" />
<asp:TemplateField HeaderText="Name" SortExpression="name">
<EditItemTemplate>
<asp:TextBox ID="TextName" runat="server" Text='<%# Eval("name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelName" runat="server" Text='<%# Eval("name") + " " + Eval("surname") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="type" HeaderText="Type" SortExpression="type" />
<asp:BoundField DataField="sub" HeaderText="Sub" SortExpression="sub" />
<asp:BoundField DataField="TotalAmount" HeaderText="Hold"
SortExpression="TotalAmount" />
<asp:BoundField DataField="loc" HeaderText="LOC" DataFormatString="{0:C}" SortExpression="loc" />
<asp:BoundField DataField="locstatus" HeaderText="LOC status"
SortExpression="locstatus" />
<asp:BoundField DataField="HoldCalc" HeaderText="OD/EX Amt" SortExpression="HoldCalc" />
<asp:BoundField DataField="odtimes" HeaderText="#OD" SortExpression="odtimes" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="gridChild" style="display: inline; position: relative; left: 15px; overflow: auto">
<asp:UpdatePanel ID="UpdateGV" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false"
BorderStyle="Double" BorderColor="#5D7B9D" Width="80%">
<HeaderStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="true"
oncheckedchanged="chkSelect_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="effective" HeaderText="Effective" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="desc_" HeaderText="Desc" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="code" HeaderText="TC" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="amount" HeaderText="Amount" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="tracer" HeaderText="Cheq #" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="empltype" HeaderText="Empl" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="balance" HeaderText="OD/EXT Amt" HeaderStyle-HorizontalAlign="Left" />
<asp:TemplateField HeaderText="Note">
<ItemTemplate>
<asp:DropDownList ID="DropDownNote" runat="server"
onselectedindexchanged="DropDownNote_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem></asp:ListItem>
<asp:ListItem>MWC</asp:ListItem>
<asp:ListItem>CBM</asp:ListItem>
<asp:ListItem>Return</asp:ListItem>
<asp:ListItem>TSF</asp:ListItem>
<asp:ListItem>OK NO S/C</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Note1">
<ItemTemplate>
<asp:DropDownList ID="ddNote2" runat="server">
<asp:ListItem Selected="True">NSF</asp:ListItem>
<asp:ListItem>Funds Not Clear</asp:ListItem>
<asp:ListItem>Post Dated</asp:ListItem>
<asp:ListItem>Stale Dated</asp:ListItem>
<asp:ListItem>Stop Payment</asp:ListItem>
<asp:ListItem>Encoding Incorrect</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Branch">
<ItemTemplate>
<asp:DropDownList ID="ddBranch" runat="server" DataSourceID="BranchDataSource"
DataTextField="branch" DataValueField="branch">
</asp:DropDownList>
<asp:SqlDataSource ID="BranchDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ThirdPartyDataConnectionString %>"
SelectCommand="SELECT [branch] FROM [branch]"></asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Account">
<ItemTemplate>
<asp:TextBox ID="TextNo" runat="server" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type">
<ItemTemplate>
<asp:DropDownList ID="ddType" runat="server" DataSourceID="typeSource"
DataTextField="Type" DataValueField="Type">
</asp:DropDownList>
<asp:SqlDataSource ID="typeSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ThirdPartyDataConnectionString %>"
SelectCommand="SELECT [Type] FROM [DMDType]"></asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sub">
<ItemTemplate><asp:TextBox ID="TextSub" Width="25px" runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownNote" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
I decided to go a different route with this, I added MaintainScrollPositionOnPostback="true" to the top line of the aspx, since the complaint from the client was that the page would go back to the top after every postback. I had originally used the UpdatePanel to remedy this but decided this would be a better option.
Now my only problem is getting the page to retain the values of the dropdown boxes after a postback which I will have to figure out how that can be done.

How to Insert Date and Time inside the Gridview

Again, New issue. Please be guided to the image below.
Here's the output (see the image below):
Here's the code of my Gridview in results.aspx
<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" DataKeyNames="ID" BorderStyle="Ridge" BackColor="White" BorderColor="Black" BorderWidth="3px" CellPadding="3" Width="1000px" AllowPaging="True" PageSize="2">
<RowStyle BackColor="White" ForeColor="#003399" HorizontalAlign="Center" VerticalAlign="Middle" />
<Columns>
<asp:boundfield DataField="Time In" HeaderText="Time In" SortExpression="Time In">
<ItemStyle Width="100px" />
</asp:boundfield>
<asp:boundfield DataField="Username" HeaderText="Bar Code No." SortExpression="Username">
</asp:boundfield>
<asp:boundfield DataField="FirstName" HeaderText="First Name" SortExpression="FirstName">
</asp:boundfield>
<asp:boundfield DataField="LastName" HeaderText="Last Name" SortExpression="LastName">
</asp:boundfield>
<asp:boundfield DataField="MiddleName" HeaderText="Middle Name" SortExpression="MiddleName">
</asp:boundfield>
<asp:boundfield DataField="ContactNumber" HeaderText="Contact No." SortExpression="ContactNumber">
</asp:boundfield>
<asp:boundfield DataField="PlateNumber" HeaderText="Plate No." SortExpression="PlateNumber">
</asp:boundfield>
<asp:boundfield DataField="Color" HeaderText="Color" SortExpression="Color">
</asp:boundfield>
<asp:boundfield DataField="Brand" HeaderText="Brand" SortExpression="Brand">
</asp:boundfield>
<asp:boundfield DataField="LiscensedNumber" HeaderText="Liscensed No." SortExpression="LiscensedNumber">
</asp:boundfield>
<asp:templatefield>
<HeaderTemplate>
Image
</HeaderTemplate>
<ItemTemplate>
<img src="data:image/jpg;base64,<%# Eval("Image") != System.DBNull.Value ? Convert.ToBase64String((byte[])Eval("Image")) : string.Empty %>" alt="image" height="85" width="85" />
</ItemTemplate>
</asp:templatefield>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="#003399" />
<EmptyDataTemplate>
No data found!
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#A0A0A0" Font-Bold="True" ForeColor="#003399" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView>
Please help. I don't know the code regarding "Date and Time" thing.
Try removing space in your datafield, as by Rahul R.
It does not matter in the Header Text but in datafield it does.
<asp:boundfield datafield="Your_Date_Column" dataformatstring="{0:MMMM d, yyyy}" htmlencode="false" />
also make sure there are no spaces in datafield name
Sorry for asking here, I solved it.
I convert the column in templatefield then I added this code
Text='<%# DateTime.Now.ToString("dddd<br /> MMMM dd, yyyy<br /> hh:mm tt") %>
:) thanks to all of you.

dropdownlist in a footer of gridview

I have asp grid view and i created 4 columns(Id,Name,quantity,price) and a footer. i have bounded all the 4 columns from the database. in the footer template, i added a dropdown list item.
every thing is working fine but, the problem is in the footer templalte dropdownlist is added after all the 4 columns but i want to add the dropdown footer to the 2nd column(Name).
Please apologise for my english n Help me
I used the following code:
<asp:GridView ID="gv_page2" runat="server" AutoGenerateColumns="False"
BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" ForeColor="Black" GridLines="Vertical" ShowFooter="True">
<AlternatingRowStyle BackColor="#CCCCCC" />
<FooterStyle BackColor="Black" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
<Columns>
<asp:BoundField DataField="PRO_ID" HeaderText="PRO_ID" />
<asp:BoundField DataField="NAME" HeaderText="NAME" ItemStyle-Width="100px"/>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate> <asp:TextBox runat="server" Width="100px"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="PRICE" ItemStyle-Width="80px"/>
<asp:BoundField HeaderText="TOTAL_PRICE"/>
<asp:TemplateField>
<FooterTempenter code herelate >
<asp:DropDownList ID="ftrDDL" runat="server" DataTextField="PRO_ID" AppendDataBoundItems="true" DataSourceID="" Width="130px" EnableViewState="true" >
<asp:ListItem Text="SELECT ONE" Value=""></asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
you need to modify the template of second column
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lblName" Text='<%# Databinder.Eval(Container.DataItem,"Name") %>'
runat="server" Width="100px"></asp:Label></ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ftrDDL" runat="server" DataTextField="PRO_ID" AppendDataBoundItems="true"
DataSourceID="" Width="130px" EnableViewState="true">
<asp:ListItem Text="SELECT ONE" Value=""></asp:ListItem>
</FooterTemplate>
</asp:TemplateField>
I have not tested the code but this should work .Let me know if it did not work
Is it required you add the drop down list in the footer?
I would suggest adding the drop down to the Name column. The footer will always load last.
Use template filed for Name
<asp:GridView ID="gv_page2" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black"
GridLines="Vertical" ShowFooter="True">
<AlternatingRowStyle BackColor="#CCCCCC" />
<FooterStyle BackColor="Black" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
<Columns>
<asp:BoundField DataField="PRO_ID" HeaderText="PRO_ID" />
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ftrDDL" runat="server" DataTextField="PRO_ID" AppendDataBoundItems="true"
DataSourceID="" Width="130px" EnableViewState="true">
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Width="100px"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="PRICE" ItemStyle-Width="80px">
<ItemStyle Width="80px"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="TOTAL_PRICE" />
</Columns>
</asp:GridView>

Resources