Good day
I have grid view with employee data displaying in it.
<asp:TabContainer ID="tcmanagers" runat="server" ActiveTabIndex="0"
Width="100%">
<asp:TabPanel ID="TabAdmins" runat="server" HeaderText="Admins" TabIndex="3">
<ContentTemplate>
<asp:Label ID="Label4" runat="server" Font-Bold="False" Font-Italic="False" CssClass="style3"
ForeColor="Blue" Width="290px">Select Admins to send:</asp:Label>
<asp:Button ID="Sendadmins" runat="server" Text="Send Email" Width="201px"/>
<br />
<br />
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" DataKeyNames="Employee_ID"
DataSourceID="SqlDataSource3" Width="633px" CssClass="grd">
<Columns>
<asp:BoundField DataField="Employee_ID" HeaderText="Employee_ID" ReadOnly="True"
SortExpression="Employee_ID" Visible="False" />
<asp:BoundField DataField="Employee_Number" HeaderText="Employee Number" SortExpression="Employee_Number">
<ItemStyle Width="70px" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Employee_Surname" HeaderText="Surname" SortExpression="Employee_Surname">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Employee_Name" HeaderText="Name" SortExpression="Employee_Name">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Employee_Job_Title" HeaderText="Job Title" SortExpression="Employee_Job_Title">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Employee_Dept" HeaderText="Department" SortExpression="Employee_Dept">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Employee_EMail" HeaderText="Email Address" SortExpression="Employee_EMail">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:TemplateField HeaderText="Check All"><HeaderTemplate>
<asp:CheckBox ID="chkAlladmin" runat="server" AutoPostBack="True" OnCheckedChanged="chkAllAdmin_CheckedChanged" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkAdmin" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns><RowStyle Font-Bold="False" Font-Italic="False" Font-Names="Arial" Font-Size="10pt" />
<EditRowStyle Font-Names="Arial" Font-Size="10pt" /><HeaderStyle Font-Bold="False" Font-Italic="False" Font-Names="Arial" Font-Size="10pt"
Font-Underline="False" CssClass="grdhead" HorizontalAlign="Center" />
<AlternatingRowStyle CssClass="grdalt" />
<SelectedRowStyle BackColor="Fuchsia" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
ProviderName="<%$ ConnectionStrings:ApplicationServices.ProviderName %>" SelectCommand="SELECT dbo.lms_Employee.Employee_ID,dbo.lms_Employee.Employee_EMail,dbo.lms_Employee.Employee_Number, dbo.lms_Employee.Employee_Surname, dbo.lms_Employee.Employee_Name, dbo.lms_Employee.Employee_Job_Title,dbo.lms_Employee.Employee_Dept FROM dbo.aspnet_Membership INNER JOIN dbo.aspnet_Users ON dbo.aspnet_Membership.UserId = dbo.aspnet_Users.UserId INNER JOIN dbo.aspnet_UsersInRoles ON dbo.aspnet_Users.UserId = dbo.aspnet_UsersInRoles.UserId INNER JOIN dbo.lms_Employee ON dbo.aspnet_Users.UserName = dbo.lms_Employee.Employee_UserName WHERE (dbo.lms_Employee.Employee_Active = 'True') AND (dbo.aspnet_UsersInRoles.RoleId = '9ec9b26d-64a1-4736-8e82-fe6de7c7caac') and Employee_Number <> '100'">
</asp:SqlDataSource>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
Now I can select all data in it or one at a time with code below.
Protected Sub chkAllAdmin_CheckedChanged(sender As Object, e As EventArgs)
For Each gr As GridViewRow In GridView3.Rows
Dim cb As CheckBox = DirectCast(gr.FindControl("chkAdmin"), CheckBox)
If DirectCast(sender, CheckBox).Checked Then
cb.Checked = True
Else
cb.Checked = False
End If
Next
End Sub
What I want to do is send a email to all the selected employees. I have an iis server and sql server. So my database is on sql server and my web application is on iis server.
I have no idea how to approached this any help will be appreciated.
Without coding it for you, here's the strategy I use for this type of task:
Convert the BoundField items to TemplateFields. When you do this, you'll likely have controls with meaningful names inside the ItemTemplate for each field, like "lblEmployeeEmail"
On your button-click, loop through the items in the GridView and for each row, use the FindControl() method to find the CheckBox (and then check if it's checked) and use the FindControl() also to get any other fields you might need. (The email label, etc.)
Here's the generic code pattern to follow (lifted from learneveryday.net):
foreach (GridViewRow gvrow in GridView1.Rows)
{
CheckBox CheckBox1 = (CheckBox)gvrow.FindControl("CheckBox1");
if (CheckBox1.Checked)
{
// we write this code for find a label value
Label lblLookFor = (Label)gvrow.FindControl("lblLookFor");
string lookfor = lblLookFor.Text;
}
}
Of course, this only covers how to get the employees that are checked and how to retrieve their email address from the GridViewRows. I'm assuming you already know how to send emails, but if not, see the MSDN documentation.
Related
I am using Visual Studio 2015 and Entity Framework 6. I have a gridview displaying orders from a database. However, I need a user to be able to click a row and be taken to another page for editing that row after a dialog box confirmation.
This is what I have:
<asp:GridView ID="gridOrders" runat="server" Height="184px" Width="1359px" AutoGenerateColumns="false"
AllowSorting="true" >
<HeaderStyle Font-Bold="true" Font-Size="16pt" BackColor="#cc0000" ForeColor="Black" />
<RowStyle Font-Size="12pt" BackColor="#afadad" ForeColor="White"/>
<AlternatingRowStyle BackColor="#afadad" ForeColor="White" />
<Columns>
<asp:CommandField HeaderText="" SelectText="CANCEL ORDER" ShowSelectButton="true" ControlStyle-ForeColor="White" />
<asp:BoundField HeaderText="First Name" DataField="FirstName" SortExpression="FirstName" />
How do I make the row selection to another page happen with a dialog that asks user if they are sure?
Change your aspx page with the below code
<asp:GridView ID="gridOrders" runat="server" Height="184px" Width="1359px" AutoGenerateColumns="False"
AllowSorting="True">
<HeaderStyle Font-Bold="true" Font-Size="16pt" BackColor="#cc0000" ForeColor="Black" />
<RowStyle Font-Size="12pt" BackColor="#afadad" ForeColor="White" />
<AlternatingRowStyle BackColor="#afadad" ForeColor="White" />
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="lnkCancelOrder" runat="server" OnClientClick="return confirm('Are you sure to redirect?')" OnClick="lnkCancelOrder_Click" CausesValidation="False" CommandArgument='<%#Eval("OrderID") %>' CommandName="Select" Text="CANCEL ORDER"></asp:LinkButton>
</ItemTemplate>
<ControlStyle ForeColor="White" />
</asp:TemplateField>
<asp:BoundField HeaderText="First Name" DataField="FirstName" SortExpression="FirstName" />
</Columns>
</asp:GridView>
Write the c# code as follows
You can redirect to another page and pass the orderID as QueryString, and retrieve the complete order information by orderID and show that in an edit mode form
protected void lnkCancelOrder_Click(object sender, EventArgs e)
{
LinkButton lnk = sender as LinkButton;
string orderID = lnk.CommandArgument;
Response.Redirect("AnotherPage.aspx?orderId="+orderID);
}
Write under the <asp:TemplateField> of Gridview as
<asp:LinkButton ID="anchrTag" runat="server" PostBackUrl="Your edit page url" OnClientClick="return confirm('Are u sure to leave this page and want to go for edit?');">Edit</asp:LinkButton>
Relative newbie here. Discovered that I have to write an event handler to handle sorting of my data from an objectdatasource. Found a lot of references to code like what's below, but when the code runs I get the message "Cannot find column xxx" where xxx is the name of the column I'm trying to sort on.
I've verified that e.SortExpression is returning the proper column name, but the problem appears to be in the 2nd line below, where I try to create a datatable (dt) from the GridView1.Datasource. The value of dt after this statement is 'nothing', so the rest of the code fails.
Also, I'm listing most of the gridview definition in case that's helpful.
Protected Sub GridView1_Sorting(sender As Object, e As GridViewSortEventArgs) Handles GridView1.Sorting
Dim dt As Data.DataTable = New Data.DataTable(GridView1.DataSource)
If Not dt Is Nothing Then
dt.DefaultView.Sort = e.SortExpression
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
ASPX snippet:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="ObjectDataSource1" CellPadding="4"
EmptyDataText="No records found for your search" ForeColor="#333333"
GridLines="None" Width="930px" BorderColor="#CCCCCC" Font-Size="12px" AllowSorting="True">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="CustName" HeaderText="CustName"
SortExpression="CustName" />
<asp:BoundField DataField="CustType" HeaderText="CustType"
SortExpression="CustType" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
<asp:TemplateField HeaderText="Address" SortExpression="Addr1">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Addr1") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Addr1") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
<asp:BoundField DataField="ContactName" HeaderText="ContactName"
SortExpression="ContactName" />
<asp:BoundField DataField="LastContactDate" HeaderText="LastContact" SortExpression="LastContactDate" dataformatstring="{0:d}" />
<asp:BoundField DataField="CustSince" HeaderText="CustSince"
SortExpression="CustSince" dataformatstring="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="Status" HeaderText="Status"
SortExpression="Status" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="Source" HeaderText="Source"
SortExpression="Source" />
<asp:BoundField DataField="RelMgr" HeaderText="RelMgr"
SortExpression="RelMgr" />
<asp:TemplateField HeaderText="RelMgrInfo">
<ItemTemplate>
<asp:HyperLink ID="RelMgrEmailLink" runat="server" NavigateUrl='<%#Eval("RelMgrEmail", "mailto:{0}")%>' Text='<%# Eval("RelMgrEmail") + "<br>" + Eval("RelMgrPhone")%> '> </asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
Thanks!
You don't have to handle the sorting event if you work with the ObjectDataSource. Instead, set the SortParameterName to a string (like "OrderBy") and augment your business method signature that ObjectDataSource uses to retrieve data with this parameter:
public IEnumerable<Whatever> Retrieve( string OrderBy, ... other arguments ) ...
The grid will pass the parameter value to the ODS and then ODS will pass it to your method.
i have a grid view inside update panel with multiple bound fields the last two bound field as shown in image when click show another grid view without post back but download not working except i set EnablePartialRendering="false" of script-manager
but in this case updatepanel not working to show bound field
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<contenttemplate>
<div id="DivImages" runat="server" visible="false" class="block rnd">
<div class="title2">الأحكـــــــــــام</div>
<div class="content2">
<asp:gridview ID="GvImages" runat="server" PagerStyle-CssClass="pages" AllowPaging="True"
AutoGenerateColumns="False" CellSpacing="-1" Width="100%" DataKeyNames="DocCode,IssuesID"
CssClass="dataGrid" OnPageIndexChanging="GvImages_PageIndexChanging" GridLines="None"
PageSize="20" OnRowCommand="GvImages_RowCommand"
OnSelectedIndexChanging="GvImages_SelectedIndexChanging">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="رقم السجــل">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DocCode" HeaderText="رقم الحكم/ القرار" SortExpression="DocCode" />
<asp:BoundField DataField="IssuesNum" HeaderText="كود القضيه"
SortExpression="IssuesNum" />
<asp:BoundField DataField="TypeName" HeaderText="نوع القضيه"
SortExpression="TypeName" />
<asp:BoundField DataField="Year" HeaderText="السنه"
SortExpression="Year" />
<asp:BoundField DataField="Area" HeaderText="المنطقه"
SortExpression="Area" />
<asp:BoundField DataField="DocTypeName" HeaderText="تصنيــف المستند" SortExpression="DocTypeName" />
<asp:BoundField DataField="Name" HeaderText="نوع المستند"
SortExpression="Name" />
<asp:TemplateField HeaderText="حذف">
<ItemTemplate>
<asp:LinkButton ID="cmd_DeleteRow" CommandName="DeleteRow" CssClass="delete" ToolTip="حذف" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" runat="server" OnClientClick="return confirmDeleteRow()" />
</ItemTemplate>
<HeaderStyle Width="125px" />
</asp:TemplateField>
<asp:CommandField SelectText="عرض" HeaderText="عرض" ShowHeader="True" ShowSelectButton="True">
<HeaderStyle HorizontalAlign="Right" />
</asp:CommandField>
<asp:TemplateField HeaderText="تحميل">
<ItemTemplate>
<asp:LinkButton ID="DownLoad" CommandName="DownLoad" Text="تحميل" ToolTip="تحميل" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" runat="server" />
</ItemTemplate>
<HeaderStyle Width="125px" />
</asp:TemplateField>
</Columns>
<RowStyle Height="25px" />
<HeaderStyle Height="30px" />
<PagerStyle CssClass="pages" Wrap="false" />
</asp:gridview>
</div>
</div>
</contenttemplate>
<Triggers>
in button search i bind my grid
like in this code
protected void ShowDoc(string sCondition)
{
//declare connection by pass connection string from web.config
SqlConnection sqlcon = new SqlConnection
(ConfigurationManager.ConnectionStrings["SystemConn"].ConnectionString);
//declare sql statment as astring variable
if (Session["Image"] != null)
{
Session.Remove("Image");
}
try
{
SqlStatment = string.Format("select distinct IssuesNum,DocType,DocTypeSub,DocCode,DocTypeName,Name,IssuesID,TypeID,TypeName,Area,IssuesNumSplited,Year from [View_ImagesSearch] Where {0} Order By [IssuesNumSplited] ASC", sCondition);
//create asql command and pass for it the connection string and sql statment
SqlCommand sqlcom = new SqlCommand(SqlStatment, sqlcon);
//create data adaptor to bring data from database
SqlDataAdapter sad = new SqlDataAdapter(sqlcom);
// declare dataset to store data from data base in it
DataSet ds = new DataSet();
//fill data set with data adabter that contain data from database
sad.Fill(ds);
lblDocCount2.Text = ds.Tables[0].Rows.Count.ToString();
Session["Image"] = ds;
GvImages.DataSource = ds;
GvImages.DataBind();
}
catch (Exception ex)
{
par_ErrorMessage.Visible = true;
par_ErrorMessage.InnerText = ex.Message;
}
}
when i click command called عرض updatepanel work to show another gridview
but when iclick item template download not workink fine untill i set EnablePartialRendering="False"
Make sure you are calling Update on the UpdatePanel after you call DataBind on the GridView:
GridView.DataBind();
UpdatePanel.Update();
See this for other possible solutions.
Hope you have a good weekend.
At long last I have got some editing/delete eventer to work with LINQ support.
I have an Add record event which I know is working, but after trying a part, I do not know how I am adding some textbox's in my footer.
So it is a row from header and down to footer, without the move to the right or the left.
Can some help me !?
My code is
<asp:GridView ID="gdview" runat="server" AutoGenerateColumns="False" DataKeyNames="test_id" OnRowCancelingEdit="gdview_RowCancelingEdit" OnRowDeleting="gdview_RowDeleting" OnRowEditing="gdview_RowEditing" OnRowUpdating="gdview_RowUpdating"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Horizontal" ShowFooter="true">
<Columns>
<asp:BoundField HeaderText="Test CAT" DataField="test_cat">
<ItemStyle Height="20px" Width="150px" />
</asp:BoundField>
<asp:BoundField HeaderText="Test INFO" DataField="test_info">
<ItemStyle Height="20px" Width="150px" />
</asp:BoundField>
<asp:BoundField HeaderText="Test NUMBER" DataField="test_number">
<ItemStyle Height="20px" Width="150px" />
</asp:BoundField>
<asp:BoundField HeaderText="Test DATE" DataField="test_datetime">
<ItemStyle Height="20px" Width="150px" />
</asp:BoundField>
<asp:CommandField ShowEditButton="True">
<ItemStyle Width="100px" />
</asp:CommandField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkdel" runat="server" Text="Delete" CommandName="Delete" OnClientClick="return confirm('Do you want to delete?')"></asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="100px" />
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#4B4B4B" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#242121" />
</asp:GridView>
Ok but how with this then work, if i use templates, how do it know what cell to get values from !??
Protected Sub gdview_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
Using db As New ThedatabaseconnectionDataContext()
Try
'getting table
Dim tbltest As Table(Of testtable) = db.GetTable(Of testtable)()
'getting an exiting row
Dim objtest As testtable = tbltest.SingleOrDefault(Function(p) p.test_id = Integer.Parse(gdview.DataKeys(e.RowIndex).Value.ToString()))
If objtest IsNot Nothing Then
'modifying the row
objtest.test_cat = DirectCast(gdview.Rows(e.RowIndex).Cells(0).Controls(0), TextBox).Text
objtest.test_info = DirectCast(gdview.Rows(e.RowIndex).Cells(1).Controls(0), TextBox).Text
objtest.test_number = DirectCast(gdview.Rows(e.RowIndex).Cells(2).Controls(0), TextBox).Text
objtest.test_datetime = DirectCast(gdview.Rows(e.RowIndex).Cells(3).Controls(0), TextBox).Text
'saving rows added
db.SubmitChanges()
gdview.EditIndex = -1
bindgrid()
' Me.lblMsg.Text = "Updated Successfully"
Else
'Me.lblMsg.Text = "Employee not found"
End If
Catch ex As Exception
'Me.lblMsg.Text = ex.Message
End Try
End Using
You can try with
<columns>
<asp:templatefield headertext="Test" >
<itemtemplate>
....
</itemtemplate>
<footertemplate>
<asp:TextBox id="TestTbx" runat="server"/>
</footertemplate>
</asp:templatefield>
</columns>
Link : http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.templatefield.footertemplate.aspx
I use the following to bind a field from the table to a hidden field inside a gridview but i am getting the error as System.Data.DataRowView' does not contain a property with the name 'AccountType'.
This is how I assigned
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hdnAccntType" runat="Server" Value='<%#Eval("AccountType") %>' />
</ItemTemplate>
</asp:TemplateField>
Is it correct or do I have to make any corrections?
My stored procedure:
CREATE DEFINER=`root`#`%` PROCEDURE `uspGetEmployeeBankDate`(_EmpID INT(11),
_BankTypeID varchar(10),_AccountType varchar(10))
BEGIN
select EmpID,BankTypeID,DATE_FORMAT(StartDate, '%Y-%m-%d')
as StartDate,DATE_FORMAT(EndDate, '%Y-%m-%d') as EndDate
from tblemployeebankdata where EmpID=_EmpID and BankTypeID=_BankTypeID
and AccountType=_AccountType;
END
Sample code
if (mlocal_ds.Tables[0].Rows.Count != 0)
{
foreach (DataRow drRow in mlocal_ds.Tables[0].Rows)
{
if (drRow["BankTypeID"].ToString() == "DbalC")
{
pnlGrid.Visible = false;
grdBank.Visible = true;
//grdData.Visible = false;
strEmpID = HiddenField1.Value;
string AccntType = drRow["AccountType"].ToString();
string strBankTypeID = drRow["BankTypeID"].ToString();
string mlocal_strStoredProcName = StoredProcNames.tblEmployeeBankdetails_uspEmployeeBankdetailsDate;
mlocal_ds = new DataSet();
oEmployee.SelectId(out mlocal_ds, mlocal_strStoredProcName, strEmpID, strBankTypeID,AccntType); // here the stored procedure is executed
grdBank.DataSource = mlocal_ds;
grdBank.DataBind();
pnlChckAcc.Visible = false;
pnlPrimary.Visible = false;
pnlSecond.Visible = false;
pnlSecondary.Visible = false;
pnlFirst.Visible = false;
pnlEditInfo.Visible = false;
break;
}
My grid view
<asp:GridView ID="grdBank" runat="server" AutoGenerateColumns="False" CellPadding="4"
CssClass="grid" ForeColor="#333333" GridLines="None" Width="349px" Visible="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButton ID="rdbtnBank" runat="server" AutoPostBack="true" OnCheckedChanged="rdbtnBank_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hdnAccntType" runat="Server" Value='<%# DataBinder.Eval(Container.DataItem, "AccountType") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="EmpID" HeaderText="EmpID">
<ItemStyle CssClass="intitalitefname" />
</asp:BoundField>
<asp:BoundField DataField="BankTypeID" HeaderText="BankTypeID">
<ItemStyle CssClass="intitalitefname" />
</asp:BoundField>
<asp:BoundField DataField="StartDate" HeaderText="Start Date">
<ItemStyle CssClass="intitalitefname" />
</asp:BoundField>
<asp:BoundField DataField="EndDate" HeaderText="End Date">
<ItemStyle CssClass="intitalitefname" />
</asp:BoundField>
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EmptyDataTemplate>
nodata to display
</EmptyDataTemplate>
</asp:GridView>
As Muhammed Akhtar said your original datasource doesn't include the AccountType field so you can't bind this to anything
You need to change your Stored Procedure to:
CREATE DEFINER=`root`#`%` PROCEDURE `uspGetEmployeeBankDate`(_EmpID INT(11),
_BankTypeID varchar(10),_AccountType varchar(10))
BEGIN
select AccountType, EmpID,BankTypeID,DATE_FORMAT(StartDate, '%Y-%m-%d')
as StartDate,DATE_FORMAT(EndDate, '%Y-%m-%d') as EndDate
from tblemployeebankdata where EmpID=_EmpID and BankTypeID=_BankTypeID
and AccountType=_AccountType;
END
The I've modified is right at the beginning of your "select" which now includes the AccountType field. If you don't include this field in your original select it's not going to be included in the datasource you get back which in turn means you can't bind it
Hope that helps
Dave
you should use the notation: <%# DataBinder.Eval(Container.DataItem, "AccountType") %>