Changing datagridview style under condition - c#

Here is a code that I have in one of my ASPX pages:
<asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="False"
HorizontalAlign="Center"
ShowHeader="False"
DataSourceID="sqlTEST1">
<Columns>
<asp:BoundField DataField="stale" Visible="false" />
<asp:BoundField DataField="bad" Visible="false" />
<asp:BoundField DataField="ping" Visible="false" />
<asp:BoundField DataField="max_tags" Visible="false" />
<asp:BoundField DataField="aval_chck" Visible="false" />
<asp:TemplateField>
<ItemTemplate>
<%
if (Eval("aval_chck").ToString()=="1")
{
<table border="0" cellpadding="2" cellspacing="1">
<tr>
<td class="rowsBLACKMAINOFF" colspan="3"><asp:Label ID="Label2" runat="server" Text='<%# Bind("instalacja") %>'></asp:Label></td>
</tr>
<tr>
<td class="rowsBLACKROWOFF"><asp:Label ID="Label2" runat="server" Text='<%# Bind("stale") %>'></asp:Label></td>
<td class="rowsBLACKROWOFF"><asp:Label ID="Label3" runat="server" Text='<%# Bind("bad") %>'></asp:Label></td>
<td class="rowsBLACKROWOFF"><asp:Label ID="Label4" runat="server" Text='<%# Bind("ping") %>'></asp:Label></td>
</tr>
</table>
}
else
{
<table border="0" cellpadding="2" cellspacing="1">
<tr>
<td class="rowsBLACKMAIN" colspan="3"><asp:Label ID="Label2" runat="server" Text='<%# Bind("instalacja") %>'></asp:Label></td>
</tr>
<tr>
<td class="rowsNORMALc"> </td>
<td class="rowsNORMALc"> </td>
<td class="rowsNORMALc"> </td>
</tr>
</table>
}
%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I know it doesn't work at all.
I only wrote logically what I want to achieve
I would like to make that statement work or do something similar to that.
Any ideas?

Try GridView.RowDataBound Event
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

Related

In grid view i cannot access the control id's from <EmptyDataTemplate> in its .ascx.cs file

wcJobShuffling.ascx
//This is an existing code in which a panel navigation contains a grid view.In its ascx.cs the intellisense is not showing the control id's from EmptyDataTemplate.
<asp:Panel ID="navigationJobs" runat="server">
<table width="98%" cellpadding="0" cellspacing="0" align="center">
<tr>
<td valign="middle" colspan="5" class="tab_not_sltd">
<table cellpadding="0" cellspacing="1" style="width: 100%;">
<tr>
<td style="width: 100%">
<table cellpadding="0" cellspacing="1" style="width: 100%;">
<tr>
<td class="print_row" style="height: 3px">
<a class="blue_nor_lnk" href="#"></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr width="98%" align="center">
<td align="left" valign="middle" width="9%" nowrap>
<asp:ImageButton ID="imgFirstPage" runat="server" align="absmiddle" border="0" SkinID="imgButtonFirst"
OnClick="imgFirstPage_Click" ToolTip="First" CausesValidation="false" />
<asp:ImageButton ID="imgPrevPage" runat="server" align="absmiddle" border="0" SkinID="imgButtonPrev"
OnClick="imgPrevPage_Click" ToolTip="Previous" CausesValidation="false" />
<span class="blue_normal">
<asp:Label ID="lblSPage" runat="server" CssClass=" blue_normal" align="absmiddle"
Width="12px"></asp:Label>
<asp:Label ID="lblto" runat="server" Text="of" CssClass="blue_normal" align="absmiddle"
Width="12px"></asp:Label>
<asp:Label ID="lblEPage" runat="server" CssClass="blue_normal" align="absmiddle"
Width="12px"></asp:Label>
<asp:Label ID="lblof" runat="server" Text="of" CssClass="blue_normal" align="absmiddle"
Visible="false"></asp:Label>
<asp:Label ID="lblTotalRecords" runat="server" CssClass=" blue_normal" align="absmiddle"></asp:Label>
</span>
<asp:ImageButton ID="imgNextPage" runat="server" align="absmiddle" border="0" SkinID="imgButtonNext"
OnClick="imgNextPage_Click" ToolTip="Next" CausesValidation="false" />
<asp:ImageButton ID="imgLastPage" runat="server" align="absmiddle" border="0" SkinID="imgButtonLast"
OnClick="imgLastPage_Click" ToolTip="Last" CausesValidation="false" />
</td>
<td align="left" valign="middle" width="7%" nowrap>
<asp:Label ID="spangoto" runat="server" Text="Go to Page: " CssClass="black_normal"></asp:Label>
<span class="blue_bold">
<asp:DropDownList ID="ddlgoto" runat="server" AutoPostBack="true" CssClass="black_normal"
OnSelectedIndexChanged="ddlgoto_SelectedIndexChanged" Width="40px">
</asp:DropDownList>
</span>
</td>
<td align="left" valign="middle" width="25%" nowrap>
<asp:Label ID="spanRpg" runat="server" Text=" Records Per Page: " CssClass="black_normal"></asp:Label>
<span class="blue_bold">
<asp:DropDownList ID="ddlRows" runat="server" AutoPostBack="true" CssClass="black_normal"
OnSelectedIndexChanged="ddlRows_SelectedIndexChanged" Width="40px">
<asp:ListItem Value="5">5</asp:ListItem>
<asp:ListItem Value="10" Selected="True">10</asp:ListItem>
<asp:ListItem Value="20">20</asp:ListItem>
<asp:ListItem Value="50">50</asp:ListItem>
</asp:DropDownList>
</span>
<asp:Label ID="lblRecords" runat="server" Text="Records found:" CssClass="black_normal"></asp:Label>
<asp:Label ID="lblTotalRecordsFound" runat="server" CssClass="black_bold"></asp:Label>
</td>
<td align="left" valign="middle" style="height: 17px; width: 10%" nowrap>
<asp:HiddenField ID="txtPageNum" runat="server" />
<asp:HiddenField ID="txtTotalpages" runat="server" />
<asp:Label ID="lblpg" CssClass="black_normal" runat="server"
Text="Page" Visible="false"></asp:Label><asp:Label ID="TotalPages" runat="server" Visible="false"></asp:Label><asp:Label ID="lblStatus" runat="server" CssClass="red_lnk"></asp:Label></td>
<td align="right" style="width: 18%">
</td>
</tr>
<tr height="5px" ><td></td></tr>
<tr align="left" style="padding-top: 3px" valign="middle">
<td colspan="5" style="width: 98%" align="left">
<div id="Gridview" width="100%">
<asp:HiddenField ID="hidColor" runat="server" />
<asp:GridView ID="gvJobShuffling" runat="server" AllowPaging="true" AutoGenerateColumns="false"
CellPadding="0" CellSpacing="1" CssClass="grid_bg" GridLines="None" OnRowDataBound="gvJobShuffling_RowDataBound"
OnSelectedIndexChanging="gvJobShuffling_SelectedIndexChanging" PagerStyle-Width="0px"
PageSize="10" ShowFooter="false" Width="100%" OnRowCancelingEdit="gvJobShuffling_RowCancelingEdit"
OnRowEditing="gvJobShuffling_RowEditing" OnRowUpdating="gvJobShuffling_RowUpdating">
<RowStyle CssClass="row_even" />
<PagerStyle CssClass="hide" />
<SelectedRowStyle CssClass="tble_hdr_not_sltd" />
<HeaderStyle CssClass="tble_hdr_not_sltd" />
<EmptyDataRowStyle CssClass="row_odd" HorizontalAlign="Center" />
<FooterStyle CssClass="hide" />
//From Here i am unable to access the control Id's ie...Imtellisense is not showing.
<EmptyDataTemplate>
<table class="confirmation">
<tr>
<td>
<asp:Label Text="Records not found" ID="lblEmpty" runat="server"></asp:Label>
</td>
</tr>
</table>
</EmptyDataTemplate>
<RowStyle CssClass="row_even" />
<AlternatingRowStyle CssClass="row_odd" />
<Columns>
<asp:TemplateField >
<HeaderTemplate>
Form ID
`` </HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblBranchID" runat="server" Text='<%# Bind("BranchID")%>'></asp:Label>
<asp:Label ID="lblProcessID" runat="server" Text='<%# Bind("ProcessID")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblBranchID" runat="server" Text='<%# Bind("BranchID")%>'></asp:Label>
<asp:Label ID="lblProcessID" runat="server" Text='<%# Bind("ProcessID")%>'></asp:Label>
</EditItemTemplate>
<ItemStyle Width="0%" />
<HeaderStyle />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="display: none" valign="middle">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" width="125px">
<a>Bill Number</a>
</td>
<td style="width: 6px">
</td>
</tr>
</table>
</td>
<td id="Img1dsc" align="right" valign="middle">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" width="125px">
<a>Bill Number</a>
</td>
<td style="width: 6px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table width="100%">
<tr>
<td>
<asp:Label ID="lblJobNumber" runat="server" Text='<%# Bind("JobNumber") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td id="Img3asc" align="right" style="display: none" valign="middle">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" width="70%">
<a>Assign To</a>
</td>
<td style="width: 6px">
</td>
</tr>
</table>
</td>
<td id="Img3dsc" align="right" valign="middle">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" width="70%">
<a>Assign To</a>
</td>
<td style="width: 6px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table width="100%">
<tr>
<td>
<%# Eval("AssignedToUserName")%>
</td>
</tr>
</table>
</ItemTemplate>
<ItemStyle Width="10%" />
//Actually in this EditItemTemplate i need to bind the ddlAssignTo.DataSource but this control property is not visible in intellinsense in wcJobsShuffling.ascx.cs
<EditItemTemplate>
<table cellpadding="0" cellspacing="0" border="0" style="padding-left: 3px">
<tr>
<td align="left" valign="middle">
<asp:DropDownList ID="ddlAssignTo" runat="server" OnSelectedIndexChanged="ddlAssignTo_SelectionIndexChanged">
</asp:DropDownList>
</td>
<td align="left" valign="middle" visible="false">
<asp:Label ID="lblSupervisorID" runat="server" Text='<%# Bind("AssignedToUserSupervisorUserID") %>' Visible="false"></asp:Label>
<asp:Label ID="lblJobId" runat="server" Text='<%# Bind("JobID") %>' Visible="false"></asp:Label>
<asp:Label ID="lblAssignedToUserName" runat="server" Text='<%# Bind("AssignedToUserName") %>'
Visible="false"></asp:Label>
</td>
</tr>
</table>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="5%">
<HeaderTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<td align="right" valign="middle" width="20%">
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0" style="padding-left: 3px">
<tr>
<td align="right" height="19px" valign="middle">
<asp:ImageButton SkinID="imgButtonEdit" runat="server" ID="imgEdit" ImageAlign="AbsMiddle"
CommandName="Edit" ToolTip="Edit" CausesValidation="false" />
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<td align="right" valign="middle" nowrap>
<asp:ImageButton SkinID="imgButtonUpdate" runat="server" ID="imgUpdate" ImageAlign="AbsMiddle"
CommandName="Update" ValidationGroup="GSave" ToolTip="Update" CausesValidation="false" />
<asp:ImageButton SkinID="imgButtonCancel" runat="server" ID="imgGCancel" ImageAlign="AbsMiddle"
CommandName="Cancel" ToolTip="Cancel" CausesValidation="false" />
</td>
</tr>
</table>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</td>
</tr>
<tr>
<td align="left" valign="middle" width="9%" style="padding-top: 5px">
<asp:ImageButton ID="imgFirstPage1" runat="server" align="absmiddle" border="0" SkinID="imgButtonFirst"
OnClick="imgFirstPage_Click" ToolTip="First" CausesValidation="false" />
<asp:ImageButton ID="imgPrevPage1" runat="server" align="absmiddle" border="0" SkinID="imgButtonPrev"
OnClick="imgPrevPage_Click" ToolTip="Previous" CausesValidation="false" />
<span class="blue_normal">
<asp:Label ID="lblpg1" runat="server" CssClass="blue_normal" align="absmiddle"></asp:Label>
<asp:Label ID="lblSPage1" runat="server" CssClass=" blue_normal" Width="12px" align="absmiddle"></asp:Label>
<asp:Label ID="lblto1" runat="server" Text="of" CssClass="blue_normal" Width="12px"
align="absmiddle"></asp:Label>
<asp:Label ID="lblEPage1" runat="server" CssClass="blue_normal" Width="12px" align="absmiddle"></asp:Label>
<asp:Label ID="lblOf1" runat="server" Text="of" CssClass="blue_normal" Visible="false"
align="absmiddle"></asp:Label>
<asp:Label ID="lblTotPages" runat="server" CssClass=" blue_normal" align="absmiddle"></asp:Label>
</span>
<asp:ImageButton ID="imgNextPage1" runat="server" align="absmiddle" border="0" SkinID="imgButtonNext"
OnClick="imgNextPage_Click" ToolTip="Next" CausesValidation="false" />
<asp:ImageButton ID="imgLastPage1" runat="server" align="absmiddle" border="0" SkinID="imgButtonNext"
OnClick="imgLastPage_Click" ToolTip="Last" CausesValidation="false" />
<asp:HiddenField ID="hidSort" runat="server" />
<asp:HiddenField ID="hidImageSort1" runat="server" />
<asp:HiddenField ID="hidImageSort2" runat="server" />
</td>
</tr>
</table>
</asp:Panel>

Gridview is not displaying footer?

Here I had given "Showfooter"=true property but still it's not displaying
But while debug value(sumofamount) is assign to label.text
My GridView Code:
<asp:GridView ID="gvGrossDetails" runat="server" AllowPaging="true" AutoGenerateColumns="false"
CellPadding="0" CellSpacing="1" CssClass="grid_bg" GridLines="None" DataKeyNames="Code"
OnRowEditing="gvPayeeGross_RowEditing" OnRowDeleting="gvGrossDetails_RowDeleting"
OnRowUpdating="gvGrossDetails_RowUpdating" OnRowCancelingEdit="gvGrossDetails_RowCancelingEdit"
PagerStyle-Width="0px" PageSize="10" ShowFooter="true" Width="112%" Style="margin-top: 0px">
<PagerStyle CssClass="hide" />
<SelectedRowStyle CssClass="tble_hdr_not_sltd" />
<HeaderStyle CssClass="tble_hdr_not_sltd" />
<EmptyDataRowStyle CssClass="row_odd" HorizontalAlign="Center" />
<FooterStyle CssClass="hide" />
<RowStyle CssClass="row_even" />
<EmptyDataTemplate>
<table class="confirmation" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:Label Text="Records not found" ID="lblEmpty" runat="server"></asp:Label>
</td>
</tr>
</table>
</EmptyDataTemplate>
<AlternatingRowStyle CssClass="row_odd" />
<Columns>
<asp:TemplateField Visible="false">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblPayeeID1" runat="server" Text='<%#Bind("Code") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="0%" />
<HeaderStyle />
</asp:TemplateField>
<asp:TemplateField Visible="false">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblPayeeCode" runat="server" Text='<%#Bind("Code") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="0%" />
<HeaderStyle />
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="20%" HeaderStyle-HorizontalAlign="Left">
<HeaderTemplate>
Account head
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblGrossType" runat="server" Text='<%# Bind("Accounthead") %>' Wrap="true"></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="item_Style1" />
<EditItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="middle" width="50%">
<asp:Label ID="txtGrossType" runat="server" Text='<%# Bind("Accounthead")%>'
CssClass="black_normal" Width="110px"></asp:Label>
</td>
</tr>
</table>
</EditItemTemplate>
<ItemStyle Width="20%" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="13%" HeaderStyle-HorizontalAlign="Left">
<HeaderTemplate>
Payee Amount
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblPresentedAmount" runat="server" Text=' <%# Eval("PayeeAmount")%>' Wrap="true"></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="item_Style1" />
<EditItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="middle">
<asp:Label ID="txtPresentedAmount" runat="server" Text='<%# Bind("PayeeAmount")%>'
CssClass="black_normal" onblur="requiredCheck(this);" MaxLength="5" Width="110px"></asp:Label>
</td>
</tr>
</table>
</EditItemTemplate>
<FooterTemplate>
<asp:Label Text=Text='<%# GetTotalSalary() %>' ID="lbltotal" runat="server"></asp:Label>
</FooterTemplate>
<ItemStyle Width="13%" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="13%" HeaderStyle-HorizontalAlign="Left">
<HeaderTemplate>
Approved Amount
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblApproveAmount" runat="server" Text='<%# Eval("ApprovedAmount")%>'
Wrap="true"></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="item_Style1" />
<EditItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="middle">
<asp:TextBox ID="txtApproveAmount" runat="server" Text='<%# Bind("ApprovedAmount")%>'
CssClass="black_normal" onblur="requiredCheck(this);" MaxLength="5" Width="110px"></asp:TextBox>
<ajaxToolkit:FilteredTextBoxExtender ID="fltrApprove" runat="server" FilterType="Custom"
FilterMode="InvalidChars" InvalidChars="'abcdefghijklmnopqrstuvwxyz#!#$%^&*%<> ,"
TargetControlID="txtApproveAmount">
</ajaxToolkit:FilteredTextBoxExtender>
</td>
</tr>
</table>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="approrve" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemStyle Width="13%" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="6%">
<HeaderTemplate>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="cursor: pointer;
cursor: hand;">
<tr>
<td align="right" style="display: none" valign="middle">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" width="70%">
<a>Delete</a>
</td>
<td style="width: 6px">
</td>
</tr>
</table>
</td>
<td align="right" valign="middle">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" width="70%">
<a>Delete</a>
</td>
<td style="width: 6px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0" style="padding-left: 3px">
<tr>
<td align="right" height="19px" valign="middle">
<asp:Button ID="btnSEdit" CssClass="btnEdit" runat="server" CommandName="Edit" UseSubmitBehavior="false"
CausesValidation="false" />
</td>
<td align="right" height="19px" valign="middle">
<asp:Button ID="btnSDelete" CssClass="btnDelete" runat="server" CommandName="delete"
UseSubmitBehavior="false" CausesValidation="false" />
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<td align="right" valign="middle" nowrap>
<asp:Button ID="btnSUpdate" CssClass="btnUpdate" runat="server" CommandName="Update"
UseSubmitBehavior="false" ValidationGroup="GSave" CausesValidation="false" />
<asp:Button ID="btnSCancel" CssClass="btnCancel" runat="server" CommandName="Cancel"
UseSubmitBehavior="false" CausesValidation="false" />
</td>
</tr>
</table>
</EditItemTemplate>
<ItemStyle Width="6%" />
</asp:TemplateField>
</Columns>
</asp:GridView>
sumof total
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Separator)
{
total += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "GrossAmount"));
}
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Separator)
{
total += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "ApprovedAmount"));
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblamount = (Label)e.Row.FindControl("lblgrossamount");
lblamount.Text = total.ToString();
}
Here i had given "Showfooter"=true property but still it's not displaying
But while debug value(sumofamount) is assign to label.text
this line apply css for the gridview infooter:
<FooterStyle CssClass="hide" />
i think that this can hide the footr of gridview pls check this css...

Page is not refreshing on button click

In my project there are number of page inheriting the same masterpage and all are responding except 1 or 2 page, there is no change in code every thing is right.
I inserted breakpoint on button click button no effect.
How can i check the Problem.
Please help
Here is the code of my page
<%# Page Title="Product Stock" Language="C#" MasterPageFile="~/admin/AdminMaster.master" AutoEventWireup="true" CodeFile="ProductStock.aspx.cs" Inherits="admin_ProductStock" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.auto-style3 {
width: 259px;
}
.auto-style4 {
width: 479px;
}
.auto-style5 {
height: 65px;
}
.auto-style6 {
width: 479px;
height: 65px;
}
.auto-style7 {
height: 74px;
}
.auto-style8 {
width: 479px;
height: 74px;
}
.auto-style9 {
width: 69px;
}
.auto-style10 {
height: 74px;
width: 68px;
}
.auto-style11 {
height: 65px;
width: 68px;
}
.auto-style12 {
width: 68px;
}
.auto-style13 {
width: 451px;
}
.auto-style14 {
width: 451px;
height: 74px;
}
.auto-style15 {
width: 451px;
height: 65px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" runat="server" contentplaceholderid="ContentPlaceHolder1">
<table style="width:100%;">
<tr>
<td>
<asp:Image ID="Image1" runat="server" Height="123px" ImageUrl="~/admin/images/insert.jpg" Width="158px" />
</td>
<td class="auto-style4">
<asp:Label ID="lblinsertion" runat="server" BackColor="#FFFF66" Font-Bold="True" Font-Italic="True" Font-Names="Euphemia" Font-Size="XX-Large" Font-Underline="True" ForeColor="#009900" Text="Insert Product Stock Information"></asp:Label>
</td>
<td class="auto-style12"> </td>
</tr>
<tr>
<td class="auto-style5">
<asp:Label ID="lblproductname" runat="server" Text="Product Name" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td class="auto-style6">
<asp:DropDownList ID="ddlprdctname" runat="server" Width="235px" ValidationGroup="vg1"></asp:DropDownList>
</td>
<td class="auto-style11">
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="ddlprdctname" ErrorMessage="Select Product Name" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblquantity" runat="server" Text="Quantity" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td class="auto-style4">
<asp:TextBox ID="txtquantity" runat="server" Width="235px" ValidationGroup="vg1"></asp:TextBox>
</td>
<td class="auto-style12">
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtquantity" ErrorMessage="Enter Quantity" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblstocktype" runat="server" Text="Stock Type" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td class="auto-style4">
<asp:DropDownList ID="ddlstocktype" runat="server" Width="235px" Height="42px" ValidationGroup="vg1"></asp:DropDownList>
</td>
<td class="auto-style12">
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="ddlstocktype" ErrorMessage="Please Enter Stock Type" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblstockdate" runat="server" Text="Stock Date" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td class="auto-style4">
<asp:TextBox ID="txtstockdate" runat="server" ValidationGroup="vg1" Height="55px" Width="235px"></asp:TextBox>
</td>
<td class="auto-style12">
<asp:Label ID="lbldateformat" runat="server" Text="dd/mm/yy"></asp:Label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtstockdate" ErrorMessage="Please Enter Stock Date" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style3"></td>
<td class="auto-style4">
<asp:Button ID="btnInsert" runat="server" Text="Insert" Width="125px" ValidationGroup="vg1" OnClick="btnInsert_Click" />
</td>
<td>
<asp:Button ID="check" runat="server" Text="Lets Check" />
</td>
<td class="auto-style12"> </td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblmsg" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
</tr>
</table>
</asp:Content>
<asp:Content ID="Content3" runat="server" contentplaceholderid="ContentPlaceHolder2">
<asp:Panel ID="ViewPanel" runat="server">
<table style="width:100%;">
<tr>
<td class="auto-style3">
<asp:Image ID="Image2" runat="server" Height="100px" ImageUrl="~/admin/images/view.jpg" Width="133px" />
</td>
<td>
<asp:Label ID="Label1" runat="server" BackColor="Yellow" Font-Bold="True" Font-Italic="True" Font-Names="Euphemia" Font-Size="XX-Large" Font-Underline="True" ForeColor="#009900" Text="View All Information"></asp:Label>
</td>
<td> </td>
</tr>
</table>
<asp:GridView ID="gridview" AutoGenerateColumns="false" runat="server" style="margin-left: 0px" AllowPaging="True" AllowSorting="True" CellPadding="3" Height="238px" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="Solid" BorderWidth="1px" CellSpacing="2" OnRowCommand="gridview_RowCommand" OnPageIndexChanging="gridview_PageIndexChanging">
<Columns>
<asp:BoundField HeaderText="Stock ID" DataField="StockID" />
<asp:BoundField HeaderText="Product Name" DataField="ProductID" />
<asp:BoundField HeaderText="Quantity" DataField="Quantity" />
<asp:BoundField HeaderText="Stock Type" DataField="StockType" />
<asp:BoundField HeaderText="Stock Date" DataField="StockDate" />
<asp:TemplateField HeaderText="Delete Record">
<ItemTemplate>
<asp:Button ID="delete" OnClientClick="return confirm('Are You Sure To Delete The Record?')" Text="Delete This Record" CommandName="del" CommandArgument='<%# Eval("StockID") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit Record">
<ItemTemplate>
<asp:Button ID="update" CommandName="upd" Text="Edit this Record" CommandArgument='<%# Eval("StockID") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
</asp:Panel>
<br />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
<asp:Label ID="lblupdate" runat="server" Text="Select the record to be updated" Font-Names="Segoe Print" Font-Size=20></asp:Label>
<asp:Panel ID="UpdatePanel" runat="server">
<table style="width:100%;">
<tr>
<td>
<asp:Image ID="Image3" runat="server" Height="123px" ImageUrl="~/admin/images/insert.jpg" Width="158px" />
</td>
<td >
<asp:Label ID="lblupdupdation" runat="server" BackColor="#FFFF66" Font-Bold="True" Font-Italic="True" Font-Names="Euphemia" Font-Size="XX-Large" Font-Underline="True" ForeColor="#009900" Text="Update Product Stock Information"></asp:Label>
</td>
<td > </td>
</tr>
<tr>
<td>
<asp:Label ID="lblupdstockid" runat="server" Text="Quantity" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtupdstockid" runat="server" ReadOnly="true" Width="235px"></asp:TextBox>
</td>
</tr>
<tr>
<td >
<asp:Label ID="lblupdproductname" runat="server" Text="Product Name" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td >
<asp:DropDownList ID="ddlupdprdctname" runat="server" Width="235px"></asp:DropDownList>
</td>
<td >
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlupdprdctname" ErrorMessage="Enter Product Name"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblupdquantity" runat="server" Text="Quantity" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtupdquantity" runat="server" Width="235px"></asp:TextBox>
</td>
<td >
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtupdquantity" ErrorMessage="Enter Quantity"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblupdstocktype" runat="server" Text="Stock Type" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td >
<asp:DropDownList ID="ddlupdstocktype" runat="server" Width="235px"></asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="ddlupdstocktype" ErrorMessage="Please Enter Stock Type"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblupdstockdate" runat="server" Text="Stock Date" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtupdstockdate" runat="server" ValidationGroup="vg1" Height="16px" Width="235px"></asp:TextBox>
</td>
<td >
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtupdstockdate" ErrorMessage="Please Enter Stock Date" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td></td>
<td >
<asp:Button ID="btnUpdate" runat="server" Text="Update" Width="125px" ValidationGroup="vg1" OnClick="btnUpdate_Click" />
</td>
<td > </td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblupdmsg" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</asp:Content>
My Client side code for button
protected void btnInsert_Click(object sender, EventArgs e)
{
try
{
int productID, quantity;
string stockType;
DateTime stockDate;
productID = int.Parse(ddlprdctname.SelectedValue);
quantity = int.Parse(txtquantity.Text.Trim());
stockType = ddlstocktype.SelectedValue.ToString().Trim();
stockDate = DateTime.Parse(txtstockdate.Text.Trim());
ProductStock prdctstock = new ProductStock();
prdctstock.ProductID = productID;
prdctstock.Quantity = quantity;
prdctstock.StockType = stockType;
prdctstock.StockDate = stockDate;
if (new InsertAction().InsertData(prdctstock))
{
lblmsg.Text = "Inserted Sucessfully";
ViewPanel.Visible = true;
}
else
{
lblmsg.Text = "Please Check all the fields";
}
BindGridView();
ProductInfo prdctinfo = new ProductInfo();
if (stockType == "In")
{
prdctinfo.Quantity += quantity;
}
if (stockType == "Out")
{
prdctinfo.Quantity -= quantity;
}
}
catch (Exception ex)
{
if (ex is FormatException)
{
lblmsg.Text = "Character value are not allowed";
}
else
{
lblmsg.Text = ex.Message;
}
}
}
Put the breakpoint somewhere where it hits. Look at the call stack and step over to the point when you find why it is not going to the method you want to trigger.
Can't do much without more information.
Hope this helps
I saw few unwanted code's
1) please remove the ValidationGroup="vg1" in your all asp.net controls except button .
2) Don't use panel , some time the button click not working on using panel control, so please use table instead of panel .(or remove the asp:panel control )
3) and must check the button click event same as server side .
4) If you give me our server side code then i will response you !!

GridView: Hide Sorting Arrows on Header

I am having difficulties hiding the sorting arrows on a column header that is not sortable.
I clearly define my sortable columns in the HeaderTemplate sections, and non sortable columns in the ItemTemplate, yet the sorting arrows still appears for the second TemplateField defined below. What am i Missing?
<asp:GridView ID="gvBeneficiary" runat="server" Width="100%" AllowPaging="True" CssClass="gridheader"
EmptyDataText=""
AutoGenerateColumns="False" PageSize="10"
OnPageIndexChanging="gvBeneficiary_PageIndexChanging" OnRowCommand="gvBeneficiary_RowCommand"
OnRowDataBound="gvBeneficiary_RowDataBound" HeaderStyle-CssClass="lhs">
<Columns>
<asp:TemplateField HeaderStyle-CssClass="lhs">
<HeaderTemplate>
<asp:LinkButton ID="lnkFullName" Text="Full Name"
CommandName="Sort" CommandArgument="FullName" runat="server"></asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<%#Eval("FullName") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkEdit" runat="server" CommandName="EditClick" CommandArgument='<%#Eval("RecipientID") %>'
Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="lnkDelete" runat="server" CommandName="DeleteClick" CommandArgument='<%#Eval("RecipientID") %>'
Text="Delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
What do u mean by defining non sortable columns in the ItemTemplate ?
Specify Allowsorting =true for the grid asd sort expression for respective columns which u want sorting to be enabled.
<asp:GridView AllowSorting="true"......../> and
<asp:TemplateField.............. SortExpression ="Full Name">
And don't specify the sort expression for columns u don't need sorting.
I think this is enough for sorting specified columns.
Is there a reason you can't use the default sorting ability in the gridview? If you can, apply the "arrows" CSS to all hyperlinks in a table header cell
.gvclass th a {background-image...}
That way all headers with a SortExpression will have those CSS properties and all non-sortable headers will not (as no hyperlink will be generated in those cells).
If you just want to disable sorting for a specific column in an event, normally it should work to set the GridViewColumn's SortExpression to null:
gvBeneficiary.Columns[0].SortExpression = null;
I have done this using listview.Please try it with Gridview
my html code is
<asp:ListView ID="lst_Area" runat="server" ItemPlaceholderID="tr" OnItemDataBound="lst_Area_ItemDataBound">
<LayoutTemplate>
<table cellspacing="0">
<tr class="hdrRowColor1">
<td width="35px" align="left">
S.No
</td>
<td align="left" width="400px">
<asp:LinkButton ID="lnk_Name" runat="server" CommandArgument="tblAreaNew.AreaName"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Name</asp:LinkButton>
<asp:Image ID="img_lnk_Name" Visible="false" runat="server" />
</td>
<td align="left" width="250px">
<asp:LinkButton ID="lnk_Location" runat="server" CommandArgument="tblAreaNew.Locationid"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Location</asp:LinkButton>
<asp:Image ID="img_lnk_Location" Visible="false" runat="server" />
</td>
<td align="left" width="175px">
<asp:LinkButton ID="lnk_CreatedBy" runat="server" CommandArgument="v.FirstName" ValidationGroup="vgSearch"
OnClick="lnk_Sort">Created By</asp:LinkButton>
<asp:Image ID="img_lnk_CreatedBy" Visible="false" runat="server" />
</td>
<td align="left" width="120px">
<asp:LinkButton ID="lnk_CreatedOn" runat="server" CommandArgument="tblAreaNew.createddate"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Created On</asp:LinkButton>
<asp:Image ID="img_lnk_CreatedOn" Visible="false" runat="server" />
</td>
<td align="left" width="175px">
<%--<asp:LinkButton ID="lnkCreatedDate" runat="server" CommandArgument="tblUserActivities.CreatedDate"
OnClick="lnk_Sort">Created Date</asp:LinkButton>--%>
<asp:LinkButton ID="lnk_LastModfiedBy" runat="server" CommandArgument="v.FirstName"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Last Modified By</asp:LinkButton>
<asp:Image ID="img_lnk_LastModfiedBy" Visible="false" runat="server" />
</td>
<td align="left" width="120px">
<asp:LinkButton ID="lnk_LastModfiedOn" runat="server" CommandArgument="tblAreaNew.ModifiedDate"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Last Modified On</asp:LinkButton>
<asp:Image ID="img_lnk_LastModfiedOn" Visible="false" runat="server" />
</td>
<td align="center" width="50px">
<asp:LinkButton ID="lnk_Status" runat="server" CommandArgument="tblAreaNew.isactive"
ValidationGroup="vgSearch" OnClick="lnk_Sort">Status</asp:LinkButton>
<asp:Image ID="img_lnk_Status" Visible="false" runat="server" />
</td>
<td align="center" width="50px" style="border-right: 1px solid #6398cc;">
Activity
<%-- <div style="width: 50px; float: right;">
</div>--%>
</td>
</tr>
<tr id="tr" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td align="left" valign="middle">
<%# Container.DataItemIndex+1 %>.
</td>
<td align="left">
<asp:Label ID="lblAreaID" runat="server" Text='<%# Eval("Areaid")%>' Visible="false"></asp:Label>
<%# Eval("AreaName")%>
</td>
<td align="left">
<%# Eval("Location")%>
</td>
<td align="left">
<%# Eval("CreatedBy")%>
</td>
<td align="left">
<%# Convert.ToDateTime(Eval("CreatedDate")).ToString("MMM, dd yyyy")%>
</td>
<td align="left">
<%# Eval("ModifiedBy")%>
</td>
<td align="left">
<%# Convert.ToDateTime(Eval("ModifiedDate")).ToString("MMM, dd yyyy")%>
</td>
<td align="center">
<asp:Label ID="lblLocationIsActive" runat="server" Style="display: none;" Text='<%# Eval("LocationIsActive")%>'></asp:Label>
<asp:Label ID="lbl_Status" runat="server" Style="display: none;" Text='<%# Eval("IsActive")%>'></asp:Label>
<asp:ImageButton ID="imgbtnStatus" runat="server" CommandArgument='<%# Eval("Areaid") %>'
OnClick="imgbtnStatus_Onclick" />
</td>
<td class="last" align="center">
<asp:Label ID="lblAreaName" runat="server" Style="display: none;" Text='<%# Eval("AreaName")%>'></asp:Label>
<asp:ImageButton ID="imgbtnEdit" runat="server" ImageUrl="~/App_Themes/ThemeNew/Images/edit.png"
ToolTip="Edit Details" CommandArgument='<%# Eval("AreaId") %>' OnClick="imgbtnEdit_OnClick" />
<asp:ImageButton ID="imgbtnDelete" runat="server" ImageUrl="~/App_Themes/ThemeNew/Images/delete.png"
ToolTip="Delete" CommandArgument='<%# Eval("AreaId") %>' Visible="false" OnClientClick="return confirm('Are you sure you want to delete the location?');"
OnClick="imgbtnDelete_OnClick" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
And my code behind code is
protected void lnk_Sort(object sender, EventArgs e)
{
LinkButton lnk = (LinkButton)sender;
string arg = lnk.CommandArgument.ToString();
ViewState["sortCol"] = arg;
GetSortDirection();
BindData(ViewState["sortCol"].ToString(), ViewState["sortDir"].ToString(), Convert.ToInt32(ViewState["nmbr"]), Pager.PageSize);
string name = lnk.ID;
Image img = (Image)(lst_Area.FindControl("img_" + name));
if (img != null)
{
SetSortOrderImage(img, ViewState["sortDir"].ToString());
}
}
private void SetSortOrderImage(Image image, String sortorder)
{
if (sortorder == "asc")
{
image.Visible = true;
image.ImageUrl = "../App_Themes/ThemeNew2/images/up.png";
}
else if (sortorder == "Desc")
{
image.Visible = true;
image.ImageUrl = "../App_Themes/ThemeNew2/images/down.png";
}
}
/// <summary>
/// this method get the sort direction
/// </summary>
private void GetSortDirection()
{
if (Convert.ToString(ViewState["sortDir"]) == "Desc")
{
ViewState["sortDir"] = "asc";
}
else
{
ViewState["sortDir"] = "Desc";
}
}
Hope this will work for you.one this more i would like to let you know the inbuilt sorting and paging are slower for gridview as compare to custom paging and sorting.

ASP.NET: How do "update" a field in the <EditItemTemplate> that has a null value in the database (SQL)

I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field is not a null value. I am not using any code behind (C#) to bind the data or manipulate the data.
I have read that when there is a null value in the database that there is no record in the "dataset". Can anyone show me how to bind a value in the form when there is a null value previously.
Thanks,
J
...
Total Records
<div style="width:1024px; text-align: justify; overflow:hidden; padding-top:0px">
<asp:GridView ID="DealershipGrid"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
CellPadding="2"
DataKeyNames="Dealership_Id"
DataSourceID="DealershipsDS"
ForeColor="#333333"
GridLines="None"
Font-Names="Tahoma"
Font-Size="9pt"
Font-Bold="False"
Width="1024px" PageSize="10">
<PagerSettings Position="TopAndBottom" />
<FooterStyle BackColor="#8b1111" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFFFF" ForeColor="#333333" Font-Names="Tahoma" Font-Size="8pt" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField
DataField="Dealership_Id"
HeaderText="ID"
InsertVisible="False"
ReadOnly="True"
SortExpression="Dealership_Id"
HeaderStyle-Width="3%"
ItemStyle-Width="3%"
FooterStyle-Width="3%" >
<FooterStyle Width="3%"></FooterStyle>
<HeaderStyle Width="3%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="3%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_Name"
HeaderText="Dealership"
SortExpression="Dealership_Name"
HeaderStyle-Width="18%"
ItemStyle-Width="18%"
FooterStyle-Width="18%">
<FooterStyle Width="18%"></FooterStyle>
<HeaderStyle Width="18%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="18%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_BranchName"
HeaderText="Branch"
SortExpression="Dealership_BranchName"
HeaderStyle-Width="18%"
ItemStyle-Width="18%"
FooterStyle-Width="18%">
<FooterStyle Width="18%"></FooterStyle>
<HeaderStyle Width="18%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="18%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_Phone1"
HeaderText="Phone"
SortExpression="Dealership_Phone1"
HeaderStyle-Width="9%"
ItemStyle-Width="9%"
FooterStyle-Width="9%" >
<FooterStyle Width="9%"></FooterStyle>
<HeaderStyle Width="9%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="9%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_Email1"
HeaderText="Email"
SortExpression="Dealership_Email1"
HeaderStyle-Width="37%"
ItemStyle-Width="37%"
FooterStyle-Width="37%">
<FooterStyle Width="37%"></FooterStyle>
<HeaderStyle Width="37%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="37%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_State"
HeaderText="State"
SortExpression="Dealership_State"
HeaderStyle-Width="5%"
ItemStyle-Width="5%"
FooterStyle-Width="5%" >
<FooterStyle Width="5%"></FooterStyle>
<HeaderStyle Width="5%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="5%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_ZipCode"
HeaderText="Zip Code"
SortExpression="Dealership_ZipCode"
HeaderStyle-Width="6%"
ItemStyle-Width="6%"
FooterStyle-Width="6%" >
<FooterStyle Width="6%"></FooterStyle>
<HeaderStyle Width="6%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="6%"></ItemStyle>
</asp:BoundField>
</Columns>
<PagerStyle BackColor="White" ForeColor="Maroon" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="False" ForeColor="#333333" />
<HeaderStyle BackColor="#AB1414" Font-Bold="True" ForeColor="White" Font-Names="Tahoma" Font-Size="9pt" HorizontalAlign="Left" />
<EditRowStyle BackColor="#999999" ForeColor="Black" />
<AlternatingRowStyle BackColor="Silver" ForeColor="Black" />
</asp:GridView>
ConnectionString="<%$ ConnectionStrings:driveaway2day2 %>"
SelectCommand="SELECT [Dealership_Id], [Dealership_Name], [Dealership_BranchName], [Dealership_Phone1], [Dealership_Email1], [Dealership_State], [Dealership_ZipCode] FROM [CAR_Dealership] ORDER BY [Dealership_Name]" EnableViewState="False" OnSelected="DealershipsDS_Selected" >
</asp:SqlDataSource>
Dealership Details
Dealership ID
<%# Eval("Dealership_Id")%>
Email 1
<%# Eval("Dealership_Email1")%>
Dealership
<%# Eval("Dealership_Name")%>
Email 2
<%# Eval("Dealership_Email2")%>
Branch Name
<%# Eval("Dealership_BranchName")%>
Email 3
<%# Eval("Dealership_Email3")%>
Phone 1
<%# Eval("Dealership_Phone1")%>
Address
<%# Eval("Dealership_Address")%>
Phone 2
<%# Eval("Dealership_Phone2")%>
City
<%# Eval("Dealership_City")%>
Phone 3
<%# Eval("Dealership_Phone3")%>
State
<%# Eval("Dealership_State")%>
Fax
<%# Eval("Dealership_Fax")%>
Zip Code
<%# Eval("Dealership_ZipCode")%>
<tr>
<td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;"> </td>
</tr>
<tr>
<td colspan="4" style="padding-top:5px;height:15px;"> </td>
</tr>
<tr>
<td colspan="2" style="padding-top:5px;">
<asp:Button ID="btnEdit" runat="Server" CommandName="Edit" Text="Edit" Font-Names="Tahoma" Font-Size="10px" />
<asp:Button ID="btnInsert" runat="Server" CommandName="New" Text="New" Font-Names="tahoma" Font-Size="10px" />
<asp:Button ID="btnDelete" runat="Server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure to Delete?');" Font-Size="10px" Font-Names="tahoma" />
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table border="0" width="1024px" style="padding-top:0px;">
<tr>
<td height="20px" colspan="4" style="padding-top:0px;"> </td>
</tr>
<tr>
<td colspan="4" style="padding-left:3px;height:20px; background-color:#E2DED6; font-family: Tahoma; font-size:12px; color:#000000; font-weight:bold; width:1024px;">Dealership Details</td>
</tr>
<tr>
<td>
<table width="800px">
<tr>
<td colspan="4" style="padding-top:5px;height:5px;"> </td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Dealership ID</td>
<td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Id")%></td>
<td style="padding-top:5px;" width="100px">Email 1</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox1" runat="Server" Text='<%# Bind("Dealership_Email1")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Dealership</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox2" runat="Server" Text='<%# Bind("Dealership_Name")%>'>
</asp:TextBox></td>
<td style="padding-top:5px;" width="100px">Email 2</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox3" runat="Server" Text='<%# Bind("Dealership_Email2")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Branch Name</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox4" runat="Server" Text='<%# Bind("Dealership_BranchName")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">Email 3</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox5" runat="Server" Text='<%# Bind("Dealership_Email3")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Phone 1</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox6" runat="Server" Text='<%# Bind("Dealership_Phone1")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">Address</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox7" runat="Server" Text='<%# Bind("Dealership_Address")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Phone 2</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox8" runat="Server" Text='<%# Bind("Dealership_Phone2")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">City</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox9" runat="Server" Text='<%# Bind("Dealership_City")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Phone 3</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox10" runat="Server" Text='<%# Bind("Dealership_Phone3")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">State</td>
<td style="padding-top:5px;" width="300px">
<asp:DropDownList class="aclDetDD" ID="myDropDownList" runat="server"
AppendDataBoundItems="True"
DataSourceID="StatesDS"
DataValueField="Dealership_State"
DataTextField="name"
SelectedValue='<%#Bind("Dealership_State") %>'>
<asp:ListItem Value="">Select a State...
</asp:ListItem>
</asp:DropDownList>
<asp:XmlDataSource ID="StatesDS" runat="server" DataFile="~/Ddl/States.xml">
</asp:XmlDataSource>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Fax</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox12" runat="Server" Text='<%# Bind("Dealership_Fax")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">Zip Code</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox13" runat="Server" Text='<%# Bind("Dealership_ZipCode")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td colspan="4" style="padding-top:5px;height:5px;"> </td>
</tr>
</tr>
</table>
</td>
<tr>
<td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;"> </td>
</tr>
<tr>
<td colspan="4" style="padding-top:5px;height:15px;"> </td>
</tr>
<asp:RequiredFieldValidator ID="req1" runat="Server" ControlToValidate="TextBox1" ErrorMessage="Email 1 is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="Server" ControlToValidate="TextBox2" ErrorMessage="Dealership is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="Server" ControlToValidate="TextBox6" ErrorMessage="Phone 1 is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="TextBox7" ErrorMessage="Address is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="TextBox9" ErrorMessage="City is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="Server" ControlToValidate="TextBox13" ErrorMessage="Zip Code is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="Server" ControlToValidate="TextBox4" ErrorMessage="Branch/Location is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="Server" ControlToValidate="myDropDownList" ErrorMessage="State is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<tr>
<td colspan="2" style="padding-top:5px;">
<asp:Button ID="btnUpdate" runat="Server" CommandName="Update" Text="Update" Font-Names="tahoma" Font-Size="10px" />
<asp:Button ID="Button1" runat="Server" CommandName="Cancel" Text="Cancel" CausesValidation="False" Font-Names="tahoma" Font-Size="10px" />
</td>
</tr>
<asp:ValidationSummary ID="ValidationSummary" runat="Server" ShowMessageBox="true" />
</table>
</EditItemTemplate>
Dealership Details
Dealership ID
<%# Eval("Dealership_Id")%>
Email 1
'>
Dealership
'>
Email 2
'>
Branch Name
'>
Email 3
'>
Phone 1
'>
Address
'>
Phone 2
'>
City
'>
Phone 3
'>
State
You might have to set null fields to default values in your dataset.

Categories