I am currently working on a web application in which I have to fetch data from database and show it in text boxes. I have these fields:
Name,Comp_Name,User_Name,Email_Id,Password,User_Image,Category,Status
and on top of it I have 1 text box where user can enter the id to see the data. For example if I write 1 in the textbox. Then the text boxes will show me the data of the record with id=1 which is stored in database.
ASPX Code:
<head runat="server">
<title>Untitled Page</title>
<link href="User.css" type="text/css" rel="Stylesheet" />
<script type="text/javascript" src="imgpreview.js"></script>
<script type="text/javascript">
function showimagepreview(input) {
if (input.files && input.files[0]) {
var filerdr = new FileReader();
filerdr.onload = function(e) {
$('#imgprvw').attr('src', e.target.result);
}
filerdr.readAsDataURL(input.files[0]);
}
}
</script>
<style type="text/css">
#Header
{
height: 65px;
}
.style1
{
height: 37px;
}
.style2
{
width: 217px;
height: 37px;
}
.style3
{
height: 37px;
width: 155px;
}
.style4
{
height: 129px;
width: 155px;
}
.style5
{
width: 217px;
height: 129px;
}
.style6
{
height: 129px;
}
</style>
<script>
window.onload=function()
{
document.getElementById("button").style.display='none';
}
function showButton(){
document.getElementById("button").style.display='block';
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="Full">
<br />
<br />
<br />
<div id="Main">
<div id="MainHead">
<asp:Panel ID="Panel1" runat="server" Height="66px">
<br />
<asp:Label ID="ID" runat="server" Text="ID"></asp:Label>
& nbsp;
<input type="text" id="userText" value="Change the text" runat="server" /> <asp:Button
ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</asp:Panel>
</div>
<br />
<table style="height: 871px; width: 504px;">
<tr>
<td class="style3">
<asp:Label ID="Name" runat="server" Font-Bold="True" ForeColor="Black"
Text="Name :"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
ControlToValidate="txtName"
Text="field required!"
runat="server" />
</td>
</tr><tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="CompName" runat="server" Font-Bold="True" ForeColor="Black"
Text="Comp Name :"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtcomp" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="UserName" runat="server" Font-Bold="True" ForeColor="Black"
Text="User Name :"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtuser" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
ControlToValidate="txtUser"
Text="field required!"
runat="server" />
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="Password" runat="server" Font-Bold="True" ForeColor="Black"
Text="Email-ID :"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3"
ControlToValidate="txtemail"
Text="field required!"
runat="server" />
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="Label5" runat="server" Font-Bold="True" ForeColor="Black"
Text="Password :"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtpass" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label6" runat="server" Font-Bold="True" ForeColor="Maroon"
Text="User Image :"></asp:Label>
</td>
<td class="style5">
<input type="file" name="filUpload" id="filUpload" onchange="showimagepreview(this)" runat="server"/>
</td>
<td class="style6">
<asp:Panel ID="Panel2" runat="server" Height="122px">
<img id="imgprvw" alt="uploaded image preview"/>
</asp:Panel>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="Label7" runat="server" Font-Bold="True" ForeColor="Black"
Text="Category :"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtcat" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="Label8" runat="server" Font-Bold="True" ForeColor="Black"
Text="Status :"></asp:Label>
</td>
<td class="style2">
<asp:DropDownList ID="txtddl" runat="server" Height="28px" Width="151px"
AutoPostBack="True">
<asp:ListItem>Store Manager</asp:ListItem>
<asp:ListItem>Pro Manager</asp:ListItem>
<asp:ListItem>Engg</asp:ListItem>
<asp:ListItem>Admin</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="Label9" runat="server" Font-Bold="True" ForeColor="Black"
Text="Category No :"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtcatno" runat="server" Height="21px" Width="151px"> </asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style2">
</td>
</tr>
<tr>
<td class="style1" colspan="2">
& nbsp; &n bsp;
<asp:Button id="Submit" runat="server" Text="Submit" onclick="Submit_Click" />
<input type="button" id="btnupd" value="New Button" runat="server" onclick="return btnupd_onclick()" />
</td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
C# Code:
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using MySql.Data.MySqlClient;
using System.Windows.Forms;
public partial class _Default : System.Web.UI.Page
{
MySqlConnection con = new MySqlConnection("DataSource=localhost;database=mrp;userid=**;password=**;port=**");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Submit_Click(object sender, EventArgs e)
{
try
{
//This is my connection string i have assigned the database file address path
string MyConnection2 = "datasource=localhost;port=**;username=**;password=**;database=mrp";
//This is my insert query in which i am taking input from the user through windows forms
string Query = "insert into user_tbl(Name,Comp_Name,User_Name,Email_Id,Password,User_Image,Category,Status) values('" + this.txtName.Text + "','" + this.txtcomp.Text + "','" + this.txtuser.Text + "','" + this.txtemail.Text + "','" + this.txtpass.Text + "','" + this.filUpload.Value + "','" + this.txtcat.Text + "','" + this.txtddl.Text + "');";
//This is MySqlConnection here i have created the object and pass my connection string.
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
//This is command class which will handle the query and connection object.
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataReader MyReader2;
MyConn2.Open();
MyReader2 = MyCommand2.ExecuteReader(); // Here our query will be executed and data saved into the database.
MessageBox.Show("Save Data");
while (MyReader2.Read())
{
}
MyConn2.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
MySqlConnection con1 = new MySqlConnection("Data Source=localhost;database=mrp;userid=**;password=**;port=**");
var str = "select * from user_tbl,con1";
DataTable dt = new DataTable();
con1.Open();
MySqlDataReader myReader = null;
MySqlCommand myCommand = new MySqlCommand("Select * from user_tbl where Id=" + Id1, con1);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
txtName.Text = (myReader["Name"].ToString());
txtemail.Text = (myReader["Email_Id"].ToString());
txtddl.Text = (myReader["Status"].ToString());
txtpass.Text = (myReader["Password"].ToString());
txtcomp.Text = (myReader["Comp_Name"].ToString());
txtuser.Text = (myReader["User_Name"].ToString());
filUpload.Value = (myReader["User_Image"].ToString());
//and whatever you have to retrieve
}
con1.Close();
}
}
Use this code snippet:
SqlConnection con1 = new SqlConnection("your connection string");
DataTable dt = new DataTable();
con1.Open();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("your query", con1);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
txtName.Text = (myReader["name"].ToString());
txtEmail.Text = (myReader["email"].ToString());
//and whatever you have to retrieve
}
con1.Close();
Related
There is a ListView which shows the data that were retrieved from the database.
I want to edit a single record on a ListView by clicking the edit button beside it but if I press the edit button, I get the error:
The ListView 'lvItemView' raised event ItemEditing which wasn't handled.
Here is the ListView:
<asp:ListView ID="lvItemView" runat="server" ItemPlaceholderID="itemHolder">
<LayoutTemplate>
<table style="color: Black;" width="100%" border="0" cellpadding="5">
<tr>
<th style="text-align: center;">Customer ID</th>
<th style="text-align: center;">Contact Name</th>
<th style="text-align: center;">Company</th>
<th style="text-align: center;">Created By</th>
<th style="text-align: center;">Created Date</th>
<th style="text-align: center;">Modified By</th>
<th style="text-align: center;">Modified Date</th>
</tr>
<asp:PlaceHolder ID="itemHolder" runat="server"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td align="left">
<asp:Label ID="lblCustomerID" runat="Server" Text='<%#Eval("_CustomerID") %>' />
</td>
<td align="left">
<asp:Label ID="lblContactName" runat="Server" Text='<%#Eval("_ContactName") %>' />
</td>
<td align="left">
<asp:Label ID="lblCompany" runat="Server" Text='<%#Eval("_CompanyID") %>' />
</td>
<td align="left">
<asp:Label ID="lblCreatedBy" runat="Server" Text='<%#Eval("_CreatedBy") %>' />
</td>
<td align="left">
<asp:Label ID="lblCreatedDate" runat="Server" Text='<%#Eval("_CreatedDate") %>' />
</td>
<td align="left">
<asp:Label ID="lblModifiedBy" runat="Server" Text='<%#Eval("_ModifiedBy") %>' />
</td>
<td align="left">
<asp:Label ID="lblModifiedDate" runat="Server" Text='<%#Eval("_ModifiedDate") %>' />
</td>
<td align="left">
<asp:LinkButton ID="EditButton" runat="Server" Text="Edit" CommandName="Edit" CommandArgument='<%#DataBinder.Eval(Container, "DataItemIndex")%>' />
</td>
<td align="left">
<asp:LinkButton ID="Delete" runat="Server" Text="Delete" CommandName="Delete" CommandArgument='<%#DataBinder.Eval(Container, "DataItemIndex")%>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
And the code behind
protected void lvItemView_ItemEditing(object sender, ListViewEditEventArgs e)
{
System.Web.UI.WebControls.Label index_id = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblCustomerID");
int customerID = int.Parse(index_id.Text);
Item item = new Item();
item._CustomerID = customerID;
System.Web.UI.WebControls.Label cmp_id = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblCompany");
int companyID = int.Parse(cmp_id.Text);
item._CompanyID = companyID;
System.Web.UI.WebControls.Label samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblContactName");
item._ContactName = samp.Text;
samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblCreatedBy");
item._CreatedBy = samp.Text;
samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblCreatedDate");
item._CreatedDate = samp.Text;
samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblModifiedBy");
item._ModifiedBy = samp.Text;
samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblModifiedDate");
item._ModifiedDate = samp.Text;
CustomerID = item._CustomerID.ToString();
ContactName = item._ContactName.ToString();
CompanyID = item._CompanyID.ToString();
CreatedBy = item._CreatedBy.ToString();
CreatedDate = item._CreatedDate.ToString();
ModifiedBy = item._ModifiedBy.ToString();
ModifiedDate = item._ModifiedDate.ToString();
modAdd.Show();
}
I am new to asp.net and c# so I have no idea what to do with this kind of error.
set the event lvItemView_ItemEditing in OnItemEditing which will be triggered when click on edit button
<asp:ListView ID="lvItemView" runat="server" ItemPlaceholderID="itemHolder" OnItemEditing="lvItemView_ItemEditing">
and also set data source if you are binding on pageload
lvItemView.DataSource = SomeData;
lvItemView.DataBind();
I have DropDownList
Whenever Data selected from the DDL, It autofills the textboxes specified.
It does get the values but does not show in the web.
Here is asp.net
<table class="col-lg-12" align="center" width="900">
<tr>
<td align="center" class="style2" valign="middle">
Name
</td>
<td align="center" class="style4" valign="middle">
ProductID
</td>
<td align="center" class="style4" valign="middle">
Price
</td>
<td align="center" class="style4" valign="middle">
Quantity
</td>
</tr>
<ItemTemplate>
<tr>
<td class="style3">
<asp:DropDownList ID="ddlName" runat="server" class="form-control"
AutoPostBack="True"
onselectedindexchanged="ddlName_SelectedIndexChanged" Width="200px"> </asp:DropDownList>
</td>
<td class="style5">
<asp:Label ID="lbID" runat="server" Width="200px"></asp:Label>
</td>
<td class="style5">
<asp:Label ID="lbPrice" runat="server" Width="200px"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="Quantity" runat="server" Width="200px"></asp:TextBox>
</td>
<td>
<asp:Button ID="AddProduct" runat="server" style="color:White"
Text="Add Product" Width="200px" onclick="AddProduct_Click" /></td>
</tr>
</ItemTemplate>
ddlSelectedIndexChanged codes
protected void ddlName_SelectedIndexChanged(object sender, EventArgs e)
{
string Name = ddlName.SelectedItem.Value;
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "SELECT Name, ProductID, Price FROM Products WHERE Name=#Name";
cmd.Parameters.AddWithValue("#Name", ddlName.SelectedValue);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
Int32 lbID = dr.GetInt32(1);
decimal lbPrice = dr.GetDecimal(2);
}
}
it doesn't fill the textboxes. Sorry for low profile question. huhuhu Help
I believe you should assign the Labels like this instead:
lbID.text = dr.GetInt32(1).ToString();
lbPrice.text = dr.GetDecimal(2).ToString();
Alternatively I would recommend looking into the DetailsView control for a more elegant, and easier in some cases, solution: DetailsVew Web Server Control
This is my event method for drop down. I need to display all record from database as selected any element from drop down list. But the following code is not working. Can you suggest any solution in the same.
protected void DropDownListSelectEmployee_SelectedIndexChanged(object sender, EventArgs e)
{
string q = "select uid,fname,mname,lname,date_format(hire_date,'%Y-%m-%d'),desg,date_format(dob,'%Y-%m-%d'),AddressLine1,AddressLine2,state,city,pincode,country,MobileNo,UserActive,username,date_format(annivarsary,'%Y-%m-%d'),email from nWorksUser where Username='" + DropDownListSelectEmployee.Text + "'";
MySqlCommand cmd = new MySqlCommand(q,conn);
conn.Open();
MySqlDataAdapter dataAdapter = new MySqlDataAdapter(q, conn);
DataTable dt = new DataTable();
dataAdapter.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
txtFirstName.Text = dr[1].ToString();
txtMiddleName.Text = dr[2].ToString();
txtLastName.Text = dr[3].ToString();
txtMobile.Text = dr[13].ToString();
txtUsername.Text = dr[15].ToString();
txtState.Text = dr[9].ToString();
txtPincode.Text = dr[11].ToString();
txtEmail.Text = dr[17].ToString();
txtDob.Text = dr[6].ToString();
txtDesignation.Text = dr[5].ToString();
txtDateofHire.Text = dr[4].ToString();
txtDateofAnnivarsary.Text = dr[16].ToString();
txtCountry.Text = dr[12].ToString();
txtCity.Text = dr[10].ToString();
txtAddressLine2.Text = dr[7].ToString();
txtAddressLine1.Text = dr[8].ToString();
if(dr[14].ToString().Length==4)
{
RdoGender.SelectedIndex = 1;
}
else
{
RdoGender.SelectedIndex = 2;
}
conn.Close();
}
}
asp code :
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="EmployeeManagementForm.aspx.cs" Inherits="WebAPP.EmployeeManagementForm" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="Content/MyStyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<header>
<h1>Employee Management</h1>
<asp:Button ID="ButtonLogOut" runat="server" Text="Log Out" class="btnLogout" />
</header>
<nav>
<button id="btnAttendance" onclick="window.location.href='AttendanceForm.aspx';return false;" class="btn">Attendance</button><br />
<button id="ButtonOnBoardEmployee" onclick="window.location.href='OnBoardEmployeeForm.aspx';return false;" class="btn">On Board Employee</button><br />
<button id="ButtonEmployeeManagement" onclick="window.location.href='EmployeeManagementForm.aspx';return false;" class="btn">Employee Management</button><br />
<button id="ButtonAdministration" onclick="window.location.href='AdministrationForm.aspx';return false;" class="btn" >Administration</button><br />
<button id="ButtonAdminManagement" onclick="window.location.href='AdminManagementForm.aspx';return false;" class="btn" >Admin Management</button><br />
<button id="ButtonEventCalendar" onclick="window.location.href='EventCalendarForm.aspx';return false;" class="btn" >Event Calendar</button><br />
</nav>
<div>
<table style="border: 1pt solid #6666FF; width: 82.9%; height: 924px; font-family: Verdana;
border-collapse: collapse; background-color: #ffffff; text-align: center;">
<tr>
<td style="text-align: center;" class="style12" colspan="3">
<asp:Label ID="lableMessage" runat="server" ForeColor="red"></asp:Label>
</td>
</tr>
<tr>
<td style="text-align: center; height: 50px;" colspan="3" class="style9">
<asp:Label ID="lblHeader" runat="server" Text="Modification Form" Font-Bold="True"></asp:Label>
</td>
</tr>
<tr>
<td class="style11" style="text-align: center;" colspan="3">
<b>Select Employee : </b>
<asp:DropDownList ID="DropDownListSelectEmployee" runat="server"
OnSelectedIndexChanged="DropDownListSelectEmployee_SelectedIndexChanged">
<asp:ListItem>nWorks Employee</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="lblFirstName" runat="server" Text="First Name :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtFirstName" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RfvFirstName" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtFirstName"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label2" runat="server" Text="Middle Name :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtMiddleName" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtMiddleName"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="lblLastName" runat="server" Text="Last Name :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtLastName" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RfvLastName" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtLastName"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="lblEmail" runat="server" Text="E-Mail :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtEmail" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RfvUserName" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtEmail"></asp:RequiredFieldValidator>
<br />
<asp:RegularExpressionValidator ID="RxvEmail" runat="server" ControlToValidate="txtEmail"
ErrorMessage="Invalid E-mail" ForeColor="#FF3300" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label3" runat="server" Text="Username :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtUsername" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtUsername"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="lblPassword" runat="server" Text="Password :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RfvPwd" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtPassword"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="lblConfirmPwd" runat="server" Text="Confirm Pasword :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtConfirmPwd" runat="server" TextMode="Password" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RfvCnfrmPwd" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtConfirmPwd"></asp:RequiredFieldValidator>
<br />
<asp:CompareValidator ID="CvCnfmPwd" runat="server" ErrorMessage="Password and Confirm Password didnt matched"
ForeColor="#FF3300" ControlToCompare="txtPassword" ControlToValidate="txtConfirmPwd"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="lblDob" runat="server" Text="Date of Birth :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtDob" runat="server" Class="style9"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="(dd/mm/yyyy)"></asp:Label>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtDob"></asp:RequiredFieldValidator>
<br />
<asp:RegularExpressionValidator ID="RxvDob" runat="server" ControlToValidate="txtDob"
ErrorMessage="Invalid Date Format" ValidationExpression="^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$"
ForeColor="#FF3300"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td style="text-align: right;" class="style11">
<asp:Label ID="lblMobile" runat="server" Text="Mobile"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtMobile" runat="server" MaxLength="10" Class="style9"></asp:TextBox>
</td>
<td class="style4">
<asp:RegularExpressionValidator ID="RxvMobile" runat="server" ErrorMessage="Invalid Mobile Number"
ForeColor="#FF3300" ValidationExpression="^([7-9]{1})([0-9]{9})$" ControlToValidate="txtMobile"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="lblAddress" runat="server" Text="Address Line 1:"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtAddressLine1" runat="server" TextMode="MultiLine" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RfvAddress" runat="server" ErrorMessage="* Required"
ForeColor="Red" ControlToValidate="txtAddressLine1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label4" runat="server" Text="Address Line 2:"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtAddressLine2" runat="server" TextMode="MultiLine" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;"></td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label5" runat="server" Text="City :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtCity" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtCity"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label6" runat="server" Text="State :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtState" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtState"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label7" runat="server" Text="Country :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtCountry" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtCountry"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label8" runat="server" Text="Pin Code :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtPincode" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtPincode"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label9" runat="server" Text="Date of Hire :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtDateofHire" runat="server" Class="style9"></asp:TextBox>
<asp:Label ID="Label10" runat="server" Text="(dd/mm/yyyy)"></asp:Label>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtDateofHire"></asp:RequiredFieldValidator>
<br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtDateofHire"
ErrorMessage="Invalid Date Format" ValidationExpression="^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$"
ForeColor="#FF3300"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label11" runat="server" Text="Date of Annivarsary :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtDateofAnnivarsary" runat="server" Class="style9"></asp:TextBox>
<asp:Label ID="Label12" runat="server" Text="(dd/mm/yyyy)"></asp:Label>
</td>
<td class="style4" style="text-align: left;"> <br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtDateofAnnivarsary"
ErrorMessage="Invalid Date Format" ValidationExpression="^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$"
ForeColor="#FF3300"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="Label13" runat="server" Text="Designation :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="txtDesignation" runat="server" Class="style9"></asp:TextBox>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="txtDesignation"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">
<asp:Label ID="lblGender" runat="server" Text="Gender :"></asp:Label>
</td>
<td class="style11" style="text-align: left;">
<asp:RadioButtonList ID="RdoGender" runat="server" RepeatDirection="Horizontal" Width="176px">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td>
<td class="style4" style="text-align: left;">
<asp:RequiredFieldValidator ID="RfvGender" runat="server" ErrorMessage="* Required"
ForeColor="#FF3300" ControlToValidate="RdoGender"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style11" style="text-align: right;">Employee Status :</td>
<td class="style11" style="text-align: left;">
<asp:RadioButtonList ID="RadioButtonsEmployeeStatus" runat="server"
RepeatDirection="Horizontal"
OnSelectedIndexChanged="RadioButtonsEmployeeStatus_SelectedIndexChanged" >
<asp:ListItem>Inactive</asp:ListItem>
<asp:ListItem>Active</asp:ListItem>
</asp:RadioButtonList></td>
<td class="style11" style="text-align: left;">
<asp:TextBox ID="TextBoxEmpInactivatedDate" runat="server" Class="style9" AutoPostBack= "True"></asp:TextBox></td>
</tr><tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td style="text-align: center;" class="style12">
</td>
<td class="style12" style="text-align: left;">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" class="btnsLikeSubmit"
/>  
<asp:Button ID="btnClear" runat="server" CausesValidation="False" class="btnsLikeSubmit"
Text="Clear" />
</td>
<td style="text-align: center;" class="style7"></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<footer>
Copyright © nWorks.co
</footer>
</div>
</form>
</body>
</html>
.aspx page
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" >
</asp:Timer>
<br />
<br />
<table style="position: absolute; top: 600px; left: 167px; width: 1010px; height: 124px;">
<tr>
<td><asp:Label ID="Label13" runat="server"></asp:Label></td>
<td >DAYS</td>
<td><asp:Label ID="Label14" runat="server"></asp:Label></div></td>
<td > HOURS</td>
<td><asp:Label ID="Label15" runat="server"></asp:Label></td>
<td >MIN</td>
<td><asp:Label ID="Label16" runat="server"></asp:Label></td>
<td > SEC</td>
<td><asp:Label ID="Label17" Text="=Remaining For Vote Day" runat="server" ></asp:Label></td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="theDiv1" runat="server" style="height: 182px;display:none">
<table align="center" class="auto-style1" style="border-style: dashed; border-color: #008000; height: 179px; width: 366px; margin-left: 300px;">
<tr>
<td class="auto-style2"> </td>
<td>
<asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="X-Large" Text="Voter login"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label2" runat="server" Text="Name"> </asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" Width="177px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label3" runat="server" Text="Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password" Width="179px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Log in" Width="65px" />
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">New User</asp:LinkButton>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Forgot Password</asp:LinkButton>
</td>
</tr>
</table>
<asp:Label ID="label4" runat="server"></asp:Label>
</div>
</Content>
.aspx.cs page
protected void Timer1_Tick(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
TimeSpan differ;
System.DateTime date1 = new System.DateTime(2015, 4, 1, 20, 10, 0);
differ = date1.Subtract(dt);
double t = differ.TotalSeconds;
if (t > 0)
{
double dy, h, m, s;
dy = differ.Days;
h = differ.Hours;
m = differ.Minutes;
s = differ.Seconds;
Label13.Text = dy.ToString();// +" Days " + h + " Hours " + m + " Minutes " + s + " Seconds left for celebration";
Label14.Text = h.ToString();
Label15.Text = m.ToString();
Label16.Text = s.ToString();
}
else
{
Timer1.Enabled = false;
time_enable.Visible = false;
theDiv1.Visible = true;
}
}
After writing theDiv1.Visible = true; this statement theDiv1 is not visible and don't work.
How can I solve it?
You have set display=none in style property and making Visible=true on server side which doesn't make sense!! so you need to do it as below
theDiv1.Style.Remove("display");//To be on safer side do this first
theDiv1.Style.Add("display","block");
or
theDiv1.Style.Add(HtmlTextWriterStyle.Display, "block");
Alternative
If you make change to your div as below
<div id="theDiv1" Visible="false" runat="server" style="height: 182px;">
then whatever code you have written will work for sure.
The problem i am facing is in this line.
decimal amount = Convert.ToDecimal(Amt.Text);
Amt.Text is not giving me the new entered value when i change it and try to save it. But it is giving me the old value. I don't know why ? Please suggest the fix.
I have a search button also in the webpage which is needed to rebind the Grid with the latest data. I think when i click the save link and gvLineItems_UpdateCommand is called , the rebinding is happening before that on the RADGRID (internally).
ASPX Code:-
<asp:content id="Content2" contentplaceholderid="MainContent" runat="server">
<script language="javascript">
function captureVal(sender, args){
alert('hi');
}
</script>
<table>
<tr>
<td>
<asp:Label ID="lblPartnerID" runat="server" Text="PartnerID" Font-Bold="true"></asp:Label>
</td>
<td>
<telerik:RadTextBox ID="tbPartnerID" runat="server" MaxLength="35" Width="243px" />
</td>
<td>
<asp:Button ID="btnSearch" runat="server" Width="80px" Visible="true" Text="Search" />
</td>
</tr>
<tr>
<td style="text-align:right">
<asp:Button ID="btnSave" runat="server" Visible="true" Text="Save" />
</td>
<td style="text-align:left">
<asp:Button ID="btnCancel" runat="server" Visible="true" Text="Cancel" />
</td>
</tr>
<tr>
<td>
Partner SSN/TIN:
</td>
<td>
<telerik:RadTextBox ID="tbPartnerEIN" runat="server" MaxLength="9" TabIndex="5">
</telerik:RadTextBox>
<label id="Label1" runat="Server" style="color: Navy">* No Dashes</label>
</td>
<td style="width:10px"></td>
<td style="text-align:left">
Address Line 1:
</td>
<td>
<telerik:RadTextBox ID="tbAddressLine1" runat="server" TabIndex="10" />
<label id="label2" runat="server" style="color: navy">
* No dashes</label>
</td>
</tr>
<tr>
<td>
Custodial EIN:
</td>
<td>
<telerik:RadTextBox ID="tbCustodialEIN" runat="server" MaxLength="9" TabIndex="10">
</telerik:RadTextBox>
<label id="Label3" runat="Server" style="color: Navy">* No Dashes</label>
</td>
<td style="width:10px"></td>
<td style="text-align:left">
Address Line 2:
</td>
<td>
<telerik:RadTextBox ID="tbAddressLine2" runat="server" TabIndex="10" />
<label id="Label4" runat="Server" style="color: Navy">
* No Dashes</label>
</td>
</tr>
<tr>
<td>
Format SSN/TIN:
</td>
<td>
<telerik:RadComboBox ID="cboFormatSSNTIN" Height="200px" runat="server" Width="246px"
TabIndex="41">
<Items>
<telerik:RadComboBoxItem Text="" Value="" />
<telerik:RadComboBoxItem Text="XXX-XX-XXXX" Value="0" />
<telerik:RadComboBoxItem Text="XX-XXXXXXX" Value="1" />
</Items>
</telerik:RadComboBox>
</td>
<td style="width:10px"></td>
<td style="text-align:left">
City:
</td>
<td>
<telerik:RadTextBox ID="tbCity" runat="server" MaxLength="22" Width="243px" TabIndex="45" />
</td>
</tr>
<tr>
<td>
Partner Name 1:
</td>
<td>
<telerik:RadTextBox ID="tbPartnerName1" runat="server" MaxLength="35" Width="243px"
TabIndex="15" />
</td>
<td style="width:10px"></td>
<td style="text-align:left">
State:
</td>
<td>
<telerik:RadComboBox ID="ddlState" runat="server" AllowCustomText="true" Filter="Contains"
Width="243px" TabIndex="35" Height="100" />
</td>
</tr>
<tr>
<td>
Partner Name 2:
</td>
<td>
<telerik:RadTextBox ID="tbPartnerName2" runat="server" MaxLength="35" Width="243px"
TabIndex="20" />
</td>
<td style="width:10px"></td>
<td style="text-align:left">
Zip:
</td>
<td>
<telerik:RadTextBox ID="tbZipcode" runat="server" MaxLength="12" Width="243px" TabIndex="55" />
</td>
</tr>
<tr>
<td>
Entity Type:
</td>
<td>
<telerik:RadComboBox ID="lbEntityType" Height="150px" runat="server" Width="246px"
TabIndex="40" />
<asp:RequiredFieldValidator ID="Requiredfieldvalidator1" runat="server" ErrorMessage="Select any one Entity type"
ControlToValidate="lbEntityType" InitialValue="0" Display="None">*</asp:RequiredFieldValidator>
</td>
<td style="width:10px"></td>
<td style="text-align:left">
Foreign Address:
</td>
<td>
<telerik:RadTextBox ID="tbForeignAddress" runat="server" Width="243px" TabIndex="35" />
</td>
</tr>
<tr>
<td colspan="2">
</td>
<td style="width:10px"></td>
<td style="text-align:left">
Domestic or Foreign:
</td>
<td>
<telerik:RadComboBox ID="lbCountry" runat="server" Width="246px" TabIndex="35" />
</td>
</tr>
<tr>
<td>
<asp:RadioButtonList ID="rbFinalAmend" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>Final K-1</asp:ListItem>
<asp:ListItem>Amended K-1</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td colspan="2">
<asp:RadioButtonList ID="rbGenLtd" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>General partner or LLC member-manager</asp:ListItem>
<asp:ListItem>Limited partner or other LLC member</asp:ListItem>
</asp:RadioButtonList>
</td>
<td style="width:10px"></td>
<td>
Nonrecourse
</td>
<td>
$<telerik:RadNumericTextBox ID="txtNonrecourse" DataType="System.Double" NumberFormat-DecimalDigits="2"
Width="200px" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
<br />
<asp:CheckBox ID="cbTax" Text="Tax basis" runat="server" />
<asp:CheckBox ID="cbGaap" Text="GAAP" runat="server" />
<asp:CheckBox ID="cbSection" Text="Section 704(b) book" runat="server" />
</td>
<td style="width:10px"></td>
<td>
Qualified nonrecourse financing
</td>
<td>
$<telerik:RadNumericTextBox ID="txtQualified" DataType="System.Double" NumberFormat-DecimalDigits="2"
Width="200px" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="cbOther" Text="Other(explain)" runat="server" />
</td>
<td style="width:10px"></td>
<td>
Recourse
</td>
<td>
$<telerik:RadNumericTextBox ID="txtRecourse" DataType="System.Double" NumberFormat-DecimalDigits="2"
Width="200px" runat="server" />
</td>
</tr>
</table>
<table>
<tr>
<td colspan="3">
<br />
<span style="font-weight: bold; font-size: 10pt">(M) Did the partner contribute property
with a built-in gain or loss?</span>
<br />
<hr size="1" />
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:RadioButtonList ID="rbContributedProperty" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList>
<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
<table>
<tr>
<td>
<table>
<tr>
<td>
<table>
<thead colspan="2">
<span style="font-weight: bold; font-size: 10pt">(L) Partner's capital account analysis</span>
</thead>
<hr size="1" />
<br />
<br />
<tr>
<td>
Beginning capital account
</td>
<td>
$<telerik:RadNumericTextBox ID="txtCapBeginning" DataType="System.Double" NumberFormat-DecimalDigits="2"
Width="200px" runat="server">
</telerik:RadNumericTextBox>
</td>
</tr>
<tr>
<td>
Capital contributed during the year
</td>
<td>
$<telerik:RadNumericTextBox ID="txtCapContributed" DataType="System.Double" NumberFormat-DecimalDigits="2"
Width="200px" runat="server">
</telerik:RadNumericTextBox>
</td>
</tr>
<tr>
<td>
Current year increase(decrease)
</td>
<td>
$<telerik:RadNumericTextBox ID="txtIncrease" DataType="System.Double" NumberFormat-DecimalDigits="2"
Width="200px" runat="server">
</telerik:RadNumericTextBox>
</td>
</tr>
<tr>
<td>
Withdrawals & distributions <span style="color: Red">(-)</span>
</td>
<td>
$<telerik:RadNumericTextBox ID="txtWithdrawals" DataType="System.Double" NumberFormat-DecimalDigits="2"
Width="200px" ForeColor="Red" runat="server">
</telerik:RadNumericTextBox>
</td>
</tr>
<tr>
<td>
Ending capital account
</td>
<td>
$<telerik:RadNumericTextBox ID="txtCapEnding" DataType="System.Double" NumberFormat-DecimalDigits="2"
Width="200px" runat="server" ReadOnly="true" />
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
</td>
<td align="center">
<b> Beginning</b>
</td>
<td align="center">
<b>Ending</b>
</td>
</tr>
<tr>
<td>
Profit
</td>
<td>
<telerik:RadNumericTextBox ID="txtBeginningProfit" DataType="System.Double"
NumberFormat-DecimalDigits="6" Width="200px" runat="server" />%
</td>
<td>
<telerik:RadNumericTextBox ID="txtEndProfit" DataType="System.Double" NumberFormat-DecimalDigits="6"
Width="200px" runat="server" />%
</td>
</tr>
<tr>
<td>
Loss
</td>
<td>
<telerik:RadNumericTextBox ID="txtBeginningLoss" DataType="System.Double"
NumberFormat-DecimalDigits="6" Width="200px" runat="server" />%
</td>
<td>
<telerik:RadNumericTextBox ID="txtEndLoss" DataType="System.Double" NumberFormat-DecimalDigits="6"
Width="200px" runat="server" />%
</td>
</tr>
<tr>
<td>
Capital
</td>
<td>
<telerik:RadNumericTextBox ID="txtBeginningCap" DataType="System.Double"
NumberFormat-DecimalDigits="6" Width="200px" runat="server" />%
</td>
<td>
<telerik:RadNumericTextBox ID="txtEndCap" DataType="System.Double" NumberFormat-DecimalDigits="6"
Width="200px" runat="server" />%
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<telerik:RadGrid runat="server" ID="gvLineItems" AllowMultiRowSelection="true" AllowMultiRowEdit="False"
AllowAutomaticUpdates="false" AllowAutomaticInserts="false" Width="100%" AllowAutomaticDeletes="False" GridLines="None" Pagesize="10"
AllowPaging="True" AutoGenerateColumns="False" PagerStyle-Mode="NextPrevAndNumeric" OnNeedDataSource="gvLineItems_NeedDataSource">
<MasterTableView InsertItemDisplay="Bottom" AutoGenerateColumns="false" AllowAutomaticUpdates="false" EditMode="InPlace"
DataKeyNames="SchK1ID,LineNumber,LineCode,Amount"
AllowAutomaticDeletes="false" Width="100%" AllowAutomaticInserts="false" CommandItemDisplay="None">
<HeaderStyle HorizontalAlign="Left" Wrap="false" />
<ItemStyle HorizontalAlign="Left"/>
<Columns>
<telerik:GridBoundColumn HeaderText="Line Number" DataField="LineNumber" SortExpression="LineNumber" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ReadOnly="true" />
<telerik:GridBoundColumn HeaderText="Line Code" DataField="LineCode" SortExpression="LineCode" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ReadOnly="true" />
<telerik:GridBoundColumn HeaderText="Description" DataField="LineDescription" SortExpression="LineDescription" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ReadOnly="true" />
<telerik:GridTemplateColumn DataType="System.Decimal" HeaderText="Amount" DataField="Amount" SortExpression="Amount" UniqueName="Amount" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" ItemStyle-VerticalAlign="Top">
<ItemTemplate><%#Eval("Amount", "{0:c}")%></ItemTemplate>
<EditItemTemplate>
<telerik:RadNumericTextBox runat="server" id="tbAmount" width="75px" EmptyMessage="0" DataType="System.Decimal" Text='<%#Eval("Amount")%>' NumberFormat-DecimalDigits="3">
</telerik:RadNumericTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridEditCommandColumn UniqueName="Save" ButtonType="LinkButton" EditText="Edit" InsertText="Insert" UpdateText="Save"/>
</Columns>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True"/>
</ClientSettings>
</telerik:RadGrid>
</td>
</tr>
</table>
C# Code Behind:
public partial class EFileK1ImageEdit : System.Web.UI.Page
{
private string m_EFSTaxPayerID;
public int PartnerId {
get {
if (!string.Empty.Equals(tbPartnerID.Text.Trim())) {
return Convert.ToInt32(tbPartnerID.Text.Trim());
}
return 0;
}
}
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack) {
this.LoadPartner();
this.PopulateCapitalAccount();
}
}
public void LoadPartner()
{
if (!(PartnerId == 0)) {
Partner p = Partner.GetEfilePartnerByID(PartnerId, ProfileExtensions.GetCurrentYear(), ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentUsername());
if ((p != null)) {
PopulateInfo(p, ProfileExtensions.GetCurrentYear());
}
}
}
public void PopulateDropDowns()
{
this.lbEntityType.DataSource = IDMS.BusinessObjects.EntityCode.GetEntityType(ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentUsername());
this.lbEntityType.DataTextField = "Explanation";
this.lbEntityType.DataValueField = "EntityCodeID";
this.lbEntityType.DataBind();
this.ddlState.DataSource = IDMS.BusinessObjects.SystemSettings.GetStateCodes(ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentUsername());
this.ddlState.DataTextField = "StateCode";
this.ddlState.DataValueField = "StateCode";
this.ddlState.DataBind();
this.ddlState.Items.FindItemByText(". ").Text = "FR";
this.lbCountry.DataSource = IDMS.BusinessObjects.MailCode.GetAllMailCodes(ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentUsername());
this.lbCountry.DataTextField = "Explanation";
this.lbCountry.DataValueField = "MailCodeID";
this.lbCountry.DataBind();
}
private void SetStateControl(string value)
{
RadComboBoxItem item = this.ddlState.FindItemByValue(value);
if (item == null) {
this.ddlState.Text = value;
} else {
item.Selected = true;
}
if (value.Trim() == ".") {
this.ddlState.Text = "";
}
}
protected void PopulateInfo(Partner p, int taxYear)
{
PopulateDropDowns();
this.tbPartnerID.Text = this.PartnerId.ToString();
}
private void PopulateCapitalAccount()
{
IDMS.BusinessObjects.CapitalAccount ca = IDMS.BusinessObjects.CapitalAccount.GetEFileCapitalAccount(this.PartnerId, ProfileExtensions.GetCurrentYear(), ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentUsername());
// SetManualAdjustmentMessage(ca)
if (ca != null) {
var _with1 = ca;
this.rbFinalAmend.Items[0].Selected = _with1.FinalK1;
this.rbFinalAmend.Items[1].Selected = _with1.AmendedK1;
this.rbGenLtd.Items[0].Selected = _with1.GeneralPartner;
this.rbGenLtd.Items[1].Selected = _with1.LimitedPartner;
this.txtBeginningCap.Value = _with1.BeginningCapitalPercent * 100;
this.txtBeginningLoss.Value = _with1.BeginningLossPercent * 100;
this.txtBeginningProfit.Value = _with1.BeginningProfitPercent * 100;
this.txtEndCap.Value = _with1.EndingCapitalPercent * 100;
this.txtEndLoss.Value = _with1.EndingLossPercent * 100;
this.txtEndProfit.Value = _with1.EndingProfitPercent * 100;
this.txtNonrecourse.Value = _with1.LiabilityShareNonRecourse;
this.txtQualified.Value = _with1.LiabilitySharedQualifiedNonRecourse;
this.txtRecourse.Value = _with1.LiabilitySharedRecourse;
} else {
this.rbContributedProperty.Items[0].Selected = false;
this.rbContributedProperty.Items[1].Selected = false;
}
}
protected void gvLineItems_UpdateCommand(object sender, GridCommandEventArgs eventData)
{
//Validate Parameters
if (eventData.Item is GridEditableItem && eventData.Item.IsInEditMode) {
DataTable dt = IDMS.BusinessObjects.EfileMapping.GetEFileLineItemsByPartner(ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentUsername(), ProfileExtensions.GetCurrentYear(), PartnerId);
//Declare Variables
GridEditableItem editableItem = eventData.Item as GridEditableItem;
int LineNumber = Convert.ToInt32(editableItem.GetDataKeyValue("LineNumber"));
string LineCode = Convert.ToString(editableItem.GetDataKeyValue("LineCode"));
decimal oldAmount = Convert.ToDecimal(dt.Select(string.Format("LineNumber={0} and LineCode='{1}'", LineNumber, LineCode))[0]["Amount"]);
RadNumericTextBox Amt = editableItem.FindControl("tbAmount") as RadNumericTextBox;
decimal amount = Convert.ToDecimal(Amt.Text);
decimal diff = amount - oldAmount;
txtIncrease.Text = (Convert.ToDecimal(txtIncrease.Text) + diff).ToString();
txtCapEnding.Text = (Convert.ToDecimal(txtCapEnding.Text) + diff).ToString();
saveCapitalAccount();
IDMS.BusinessObjects.EfileMapping.UpdateEFileLineItemsByPartner(ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentUsername(), ProfileExtensions.GetCurrentYear(), PartnerId, amount, LineNumber, LineCode);
}
}
protected void gvLineItems_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
gvLineItems.DataSource = IDMS.BusinessObjects.EfileMapping.GetEFileLineItemsByPartner(ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentUsername(), ProfileExtensions.GetCurrentYear(), PartnerId);
}
protected void btnSearch_Click(object sender, EventArgs e)
{
this.LoadPartner();
this.PopulateCapitalAccount();
gvLineItems.Rebind();
}
private void btnSave_Click(object sender, System.EventArgs e)
{
IDMS.BusinessObjects.Partner p = new IDMS.BusinessObjects.Partner();
var _with2 = p;
_with2.PartnerID = int.Parse(tbPartnerID.Text);
_with2.EFSNameLine1 = tbPartnerName1.Text;
UpdateEFileDetailPartnerGridByYear(ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentYear(), this.PartnerId);
}
public void saveCapitalAccount()
{
IDMS.BusinessObjects.CapitalAccount ca = new IDMS.BusinessObjects.CapitalAccount();
var _with3 = ca;
_with3.PartnerID = this.PartnerId;
_with3.CalendarYear = ProfileExtensions.GetCurrentYear();
_with3.FinalK1 = this.rbFinalAmend.Items[0].Selected;
_with3.AmendedK1 = this.rbFinalAmend.Items[1].Selected;
_with3.GeneralPartner = this.rbGenLtd.Items[0].Selected;
_with3.LimitedPartner = this.rbGenLtd.Items[1].Selected;
_with3.BeginningCapitalPercent = this.txtBeginningCap.Value.GetValueOrDefault(0) / 100;
_with3.BeginningLossPercent = this.txtBeginningLoss.Value.GetValueOrDefault(0) / 100;
_with3.BeginningProfitPercent = this.txtBeginningProfit.Value.GetValueOrDefault(0) / 100;
_with3.EndingCapitalPercent = this.txtEndCap.Value.GetValueOrDefault(0) / 100;
_with3.EndingLossPercent = this.txtEndLoss.Value.GetValueOrDefault(0) / 100;
_with3.EndingProfitPercent = this.txtEndProfit.Value.GetValueOrDefault(0) / 100;
_with3.LiabilityShareNonRecourse = this.txtNonrecourse.Value.GetValueOrDefault(0);
_with3.LiabilitySharedQualifiedNonRecourse = this.txtQualified.Value.GetValueOrDefault(0);
_with3.LiabilitySharedRecourse = this.txtRecourse.Value.GetValueOrDefault(0);
_with3.AccountAnalysisBeginningCapital = this.txtCapBeginning.Value.GetValueOrDefault(0);
_with3.AccountAnalysisContributions = this.txtCapContributed.Value.GetValueOrDefault(0);
_with3.AccountAnalysisIncreaseDecrease = this.txtIncrease.Value.GetValueOrDefault(0);
_with3.AccountAnalysisWithdrawalsDistributions = this.txtWithdrawals.Value.GetValueOrDefault(0);
_with3.AccountAnalysisEndingCapital = _with3.AccountAnalysisBeginningCapital + _with3.AccountAnalysisContributions + _with3.AccountAnalysisIncreaseDecrease - _with3.AccountAnalysisWithdrawalsDistributions;
_with3.AccountAnalysisGAAP = this.cbGaap.Checked;
_with3.AccountAnalysisOther = this.cbOther.Checked;
_with3.AccountAnalysisSection704b = this.cbSection.Checked;
_with3.AccountAnalysisTaxBasis = this.cbTax.Checked;
_with3.ContributePropertyYes = this.rbContributedProperty.Items[0].Selected;
_with3.ContributePropertyNo = this.rbContributedProperty.Items[1].Selected;
_with3.SaveEfile(ProfileExtensions.GetCurrentClient(), ProfileExtensions.GetCurrentUsername());
}
public EFileK1ImageEdit()
{
Load += Page_Load;
Init +=EFileK1ImageEdit_Init;
}
private void EFileK1ImageEdit_Init(object sender, EventArgs e)
{
btnSave.Click+=btnSave_Click;
btnCancel.Click +=btnCancel_Click;
btnSearch.Click+=btnSearch_Click;
gvLineItems.NeedDataSource +=gvLineItems_NeedDataSource;
gvLineItems.UpdateCommand +=gvLineItems_UpdateCommand;
}
}