Pages

Monday, February 20, 2012

GridView Update All Rows At Once in asp.net

private void Update()
{
StringBuilder sb = new StringBuilder();
// build the query
foreach (GridViewRow row in GridView1.Rows)
{
sb.Append("UPDATE Users SET FirstName = '");
sb.Append((row.FindControl("txtFirstName") as TextBox).Text);
sb.Append("',");
sb.Append("LastName = '");
sb.Append((row.FindControl("txtLastName") as TextBox).Text);
sb.Append("', ");
sb.Append("ClassCode = '");
sb.Append((row.FindControl("txtClassCode") as TextBox).Text);
sb.Append("'");
sb.Append(" WHERE UserID = ");
sb.Append(Convert.ToInt32((row.FindControl("lblUserID") as Label).Text));
sb.Append(" ");
}
string connectionString =
"Server=HCUBE008;Database=School;Trusted_Connection=true";
SqlConnection myConnection = new SqlConnection(connectionString);
SqlCommand myCommand = new SqlCommand(sb.ToString(), myConnection);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
}

Bind Data Dynamically To Drop Down List in gridview in asp.net


 ASPX Code:

 <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False" HeaderStyle-BackColor="#EDEDED" HeaderStyle-ForeColor="#184F46" HeaderStyle-Height="40px" HeaderStyle-HorizontalAlign="Center" OnRowDataBound="Gridview1_RowDataBound" SelectedRowStyle-BackColor="#F9CACA" ShowFooter="True" TabIndex="9" Width="100%">
<asp:TemplateField HeaderStyle-Height="30px" HeaderText="Package Type">
<ItemTemplate>
 <asp:DropDownList ID="ddlPackageType" runat="server"  Width="70px">
  </asp:DropDownList>
  </ItemTemplate>
  <HeaderStyle Height="30px" Width="8%" />
  <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>
</GridView>


CODE Behind Code for Binding Data  :

protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
           
            DataSet dsPackageType = new DataSet();
      //Write Code For Getting data from Database and add it in dsPackageType Dataset .        

           if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Control ctrl = e.Row.FindControl("ddlPackageType");
                if (ctrl != null)
                {

                    DropDownList dd = ctrl as DropDownList;
                    dd.DataTextField = "PackageType";
                    dd.DataValueField= "Id";
                    dd.DataSource = dsPackageType;
                    dd.DataBind();
                    dd.Items.Insert(0, new ListItem("- Select -", "0"));

                }

            }
}

How to round numbers in java Script


Option1 : Math.Round()

Jave Script For rounding the numbers to required decimals ...

<script language="javascript" type="text/javascript">
function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
document.roundform.numberfield.value = parseFloat(newnumber); // Output the result to the form field (change for your
purposes)
}
</script>


Simple HTM For for Rounding the numbers 

<form name="roundform">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td>Round:</td>
<td><input type="text" name="numberfield" value="">
to
<input name="decimalfield" type="text" value="2" size="3">
decimal places</td>



Option 2: toFixed (beta)

Java Script
<script type="text/javascript">
function roundNumber(number, decimals) { // Arguments: number to round, number of decimal places
var newnumber = new Number(number+'').toFixed(parseInt(decimals));
document.roundform.roundedfield.value = parseFloat(newnumber); // Output the result to the form field (change for your purposes)
}
</script>

Sample HTML Form 

<form name="roundform">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td>Round:</td>
<td><input type="text" name="numberfield" value="">
to
<input name="decimalfield" type="text" value="2" size="3">
decimal places</td>













Tuesday, January 17, 2012

MX record



A mail exchanger record (MX record) is a type of resource record in the Domain Name System that specifies a mail server responsible for accepting email messages on behalf of a recipient's domain, and a preference value used to prioritize mail delivery if multiple mail servers are available. The set of MX records of a domain name specifies how email should be routed with the Simple Mail Transfer Protocol.



Wednesday, January 11, 2012

Features of SQL SERVER 2008R2



PowerPivot for SharePoint
PowerPivot for SharePoint adds shared services and infrastructure for loading, querying, and managing PowerPivot workbooks that you publish to a SharePoint 2010 server or farm. To create PowerPivot workbooks, you use PowerPivot for Excel. 


  PowerPivot for Excel
PowerPivot for Excel is an add-in to Excel 2010 that can be downloaded from the web and installed on client workstations. You use PowerPivot for Excel to assemble and create relationships in large amounts of data from different sources, and then use that data as the basis for PivotTables and other data visualization objects that support data analysis in Excel. 


  Multi-Server Administration and Data-Tier Application
The SQL Server Utility forms a central repository for performance data and management policies that tailor the operation of instances of the Database Engine that have been enrolled in the utility. It also includes a Utility Explorer for centralized management, and dashboards that report the state of the managed instances. A data-tier application (DAC) forms a single unit for developing, deploying, and managing the database objects used by an application.


  Master Data Services 
Master Data Services is comprised of a database, configuration tool, Web application, and Web service that you use to manage your organization's master data and maintain an auditable record of that data as it changes over time. You use models and hierarchies to group and organize data to prepare it for further use in business intelligence and reporting tools, data warehouses, and other operational systems. Master Data Services integrates with source systems and incorporates business rules to become the single source of master data across your organization.


  Features Supported by the Editions of SQL Server 2008 R2 
The largest database supported by SQL Server Express has been increased from 4 GB to 10 GB.


  Connecting to the Database Engine Using Extended Protection


SQL Server now supports Extended Protection, using service binding and channel binding to help prevent an authentication relay attack. Also, see Extended Protection for Authentication with Reporting Services.