<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UpdateClientMapping.aspx.cs" Inherits="AttendanceWinmethods.UpdateClientMapping" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> Client Mapping Details </div> <div> <br /> <br /> <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" Width="500px" OnRowDataBound="GridView2_RowDataBound" > <Columns> <asp:TemplateField HeaderText="ParentClientID"> <HeaderStyle HorizontalAlign="Left" Width="150px" /> <ItemStyle HorizontalAlign="Left" /> <ItemTemplate> <%#Eval("ParentClientID")%> <asp:DropDownList ID="ddlParentClientID" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="IntermediateClientID"> <HeaderStyle HorizontalAlign="Left" Width="150px" /> <ItemStyle HorizontalAlign="Left" /> <ItemTemplate> <%#Eval("IntermediateClientID")%></ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlIntermediateClientID" runat="server"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ActualClientID"> <HeaderStyle HorizontalAlign="Left" Width="150px" /> <ItemStyle HorizontalAlign="Left" /> <ItemTemplate> <%#Eval("ActualClientID")%></ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlActualClientID" runat="server"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="btnedit" runat="server" CommandName="Edit" Text="Edit" /> </ItemTemplate> <EditItemTemplate> <asp:LinkButton ID="btnupdate" runat="server" CommandName="Update" Text="Update" /> <asp:LinkButton ID="btncancel" runat="server" CommandName="Cancel" Text="Cancel" /> </EditItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; namespace AttendanceWinmethods { public partial class UpdateClientMapping : System.Web.UI.Page { string strConnection = ConfigurationManager.ConnectionStrings["SQLConnection"].ToString(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) BindData(); } #region Business Layer private void BindData() { //Bind the grid view GridView2.DataSource = GetClientMappingDetails(); GridView2.DataBind(); } protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DropDownList ddlParentClientID = (DropDownList)e.Row.FindControl("ddlParentClientID"); //Bind subcategories data to dropdownlist ddlParentClientID.DataTextField = "ClientName"; ddlParentClientID.DataValueField = "ClientID"; ddlParentClientID.DataSource = RetrieveParentClientID(); ddlParentClientID.DataBind(); DataRowView dr = e.Row.DataItem as DataRowView; ddlParentClientID.SelectedValue = dr["ParentClientID"].ToString(); } } #endregion; #region Data Layer private DataSet GetClientMappingDetails() { if (ViewState["ClientIDS"] != null) return (DataSet)ViewState["ClientIDS"]; string strConnection = ConfigurationManager.ConnectionStrings["SQLConnection"].ToString(); SqlConnection con = new SqlConnection(strConnection); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "WM_Prc_Get_ClientMappingDetails"; cmd.CommandType = CommandType.StoredProcedure; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); return ds; } #endregion; public object ds { get; set; } protected DataTable RetrieveParentClientID() { string strConnection = ConfigurationManager.ConnectionStrings["SQLConnection"].ToString(); SqlConnection con = new SqlConnection(strConnection); // String str = "select CM.ParentClientID, CD.ClientName from ClientDetails as CD,ClientMapping as CM where CD.ClientID=CM.ParentClientID"; String str = "select ClientName, ClientID from ClientDetails"; SqlCommand cmd = new SqlCommand(str, con); //cmd.Connection = con; //cmd.CommandText = "WM_Prc_Get_ClientMappingDetails"; //cmd.CommandType = CommandType.StoredProcedure; DataTable dt = new DataTable(); // DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); return dt; } public object dt { get; set; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)