Thursday, July 26, 2007

GridView Update All Rows At Once









' />




' />




' runat="server" Text='<%# Eval("coprowno") %>' />
' runat="server" Text='<%# Eval("coprowno") %>' />




' runat="server" Text='<%# Eval("cocomtot") %>' />
' runat="server" Text='<%# Eval("cocomtot") %>' />













using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Reflection;
using System.Text;

public partial class Default6 : System.Web.UI.Page
{
private bool isEditMode = false;
protected bool IsInEditMode
{
get { return this.isEditMode; }
set { this.isEditMode = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
{
isEditMode = true;
BindData();
}
}
private void BindData()
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
string strSQL;
strSQL = "SELECT * FROM [ovowproty]";
//Response.Write(strSQL);
//Response.End();
SqlDataAdapter ad = new SqlDataAdapter(strSQL, myConnection);
DataSet ds = new DataSet();
ad.Fill(ds);
MyGridView.DataSource = ds;
//isEditMode = true;
MyGridView.DataBind();


}
private void Update()
{
StringBuilder sb = new StringBuilder();
// build the query
foreach (GridViewRow row in MyGridView.Rows)
{
sb.Append("UPDATE ovowproty SET coprowno = '");
sb.Append((row.FindControl("coprowno") as TextBox).Text);
sb.Append("', ");
sb.Append("cocomtot = '");
sb.Append((row.FindControl("cocomtot") as TextBox).Text);
sb.Append("'");
sb.Append(" WHERE coOwnerID = ");
sb.Append(Convert.ToInt32((row.FindControl("coOwnerID") as Label).Text));
sb.Append(" and coProComTy=");
sb.Append("'");
sb.Append(Convert.ToString((row.FindControl("coProComTy") as Label).Text));
sb.Append("'");
}
// string connectionString = "Server=HCUBE008;Database=School;Trusted_Connection=true";
Response.Write(sb.ToString());
// Response.End();
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlCommand myCommand = new SqlCommand(sb.ToString(), myConnection);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
}




private string ConnectionString
{
get
{
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
return connectionString;
}
}






protected void Button2_Click(object sender, EventArgs e)
{
Update();
}
}



http://www.svdeals.com/ super value deals





Tuesday, July 24, 2007

Unable to Close Popup window using ASP.Net - .NET C#

Unable to Close Popup window using ASP.Net - .NET C#: "Unable to Close Popup window using ASP.Net "
Response.Write("");


Response.End();



http://www.svdeals.com/ super hit deals.

Monday, July 23, 2007

Tuesday, July 17, 2007

See Who Is Blocking Your SQL Server

See Who Is Blocking Your SQL Server: "See Who Is Blocking Your SQL Server"
See Who Is Blocking Your SQL Server
If you have ever monitored any blocking problems in SQL Server, you know that sp_who only shows you the spid (SQL Server's internal Process ID) that is causing the blocking for each spid that is blocked. Often a blocked spid is shown as causing blocking for another spid. To see the spid (or spids) that started the whole mess off, execute the following SQL:
SELECT p.spid
,convert(char(12), d.name) db_name
, program_name
, convert(char(12), l.name) login_name
, convert(char(12), hostname) hostname
, cmd
, p.status
, p.blocked
, login_time
, last_batch
, p.spid
FROM master..sysprocesses p
JOIN master..sysdatabases d ON p.dbid = d.dbid
JOIN master..syslogins l ON p.suid = l.suid
WHERE p.blocked = 0
AND EXISTS ( SELECT 1
FROM master..sysprocesses p2
WHERE p2.blocked = p.spid )
We built this into our own version of sp_who, called sp_hywho. See the listing below.
Code for sp_hywho: if exists (select * from sysobjects
where id = object_id('dbo.sp_hywho')
and sysstat & 0xf = 4)
drop procedure dbo.sp_hywho
GO
Create Procedure sp_hywho
( @vcDBName sysname = NULL )
AS
SET NOCOUNT ON
IF EXISTS ( SELECT 1
FROM master..sysprocesses p
WHERE p.blocked = 0
AND EXISTS ( SELECT 1
FROM master..sysprocesses p2
WHERE p2.blocked = p.spid ) )
BEGIN
PRINT "Blocking caused by:"
PRINT ""
SELECT p.spid
,convert(char(12), d.name) db_name
, program_name
, convert(char(12), l.name) login_name
, convert(char(12), hostname) hostname
, cmd
, p.status
, p.blocked
, login_time
, last_batch
, p.spid
FROM master..sysprocesses p
JOIN master..sysdatabases d ON p.dbid = d.dbid
JOIN master..syslogins l ON p.suid = l.suid
WHERE p.blocked = 0
AND EXISTS ( SELECT 1
FROM master..sysprocesses p2
WHERE p2.blocked = p.spid )
AND (p.dbid = DB_ID( @vcDBName ) OR @vcDBName IS NULL)
ORDER BY 2,IsNull(Ltrim(program_name),"ZZZZZZZZZ"),4,5
PRINT ""
END
SELECT p.spid
,convert(char(12), d.name) db_name
, program_name
, convert(char(12), l.name) login_name
, convert(char(12), hostname) hostname
, cmd
, p.status
, p.blocked
, login_time
, last_batch
, p.spid
FROM master..sysprocesses p
JOIN master..sysdatabases d ON p.dbid = d.dbid
JOIN master..syslogins l ON p.suid = l.suid
WHERE (p.dbid = DB_ID( @vcDBName ) OR @vcDBName IS NULL)
ORDER BY 2,IsNull(Ltrim(program_name),"ZZZZZZZZZ"),4,5
SET NOCOUNT OFF
GO
if exists (select * from sysobjects
where id = object_id('dbo.sp_hywho')
and sysstat & 0xf = 4)
GRANT EXEC ON dbo.sp_hywho TO PUBLIC
GO

www.svdeals.com super hotttt dealssss

Friday, July 13, 2007

Monday, July 9, 2007

Web Server Calendar Control in ASP.NET 2.0

Web Server Calendar Control in ASP.NET 2.0: "Web Server Calendar Control in ASP.NET 2.0"

www.svdeals.com

Control ctl00 of type 'GridView' must be placed inside a form tag with runat=server

CodeSnip: Exporting GridView to Excel: ASP Alliance

This is pretty confusing, since your GridView is already inside the form tags and also contains the runat = server attribute. You can easily resolve this error by adding the following lines.

Listing 3: Overiding VerifyRenderingInServerForm Method
public override void VerifyRenderingInServerForm(Control control)
{
/* Confirms that an HtmlForm control is rendered for the specified ASP.NET
server control at run time. */
}


www.svdeals.com super hot deals

Thursday, July 5, 2007

How to convert string to double C# Friends

How to convert string to double C# Friends: "How to convert string to double"

www.svdeals.com

gridView cummulative total on level break

if (e.Row.Cells[1].Text!=shiptp122)
{
RunTot = 0;
}
RunTot += (Convert.ToInt32(e.Row.Cells[2].Text));
e.Row.Cells[3].Text = Convert.ToString(RunTot);
shiptp122 = e.Row.Cells[1].Text;

www.svdeals.com cummulative total

Tutorial 15: Displaying Summary Information in the GridView's Footer

Tutorial 15: Displaying Summary Information in the GridView's Footer: "Tutorial 15: Displaying Summary Information in the GridView's Footer"

cummulative sum

deals - www.visli.com

GridViewRowCollection.Count Property (System.Web.UI.WebControls)

GridViewRowCollection.Count Property (System.Web.UI.WebControls): "GridViewRowCollection.Count Property"


http://www.visli.com/ super duper deals

Tuesday, July 3, 2007

Creating a Crosstab Report in Visual Studio 2005 Using Crystal Reports: ASP Alliance

Creating a Crosstab Report in Visual Studio 2005 Using Crystal Reports: ASP Alliance: "Creating a Crosstab Report in Visual Studio 2005 Using Crystal Reports"

www.svdeals.com

CodeSnip: How to Display Sum Total in the Footer of the GridView Control: ASP Alliance

CodeSnip: How to Display Sum Total in the Footer of the GridView Control: ASP Alliance: "CodeSnip: How to Display Sum Total in the Footer of the GridView Control"


www.svdeals.com

MS SQL Server: Rollup with Datetime by Year

MS SQL Server: Rollup with Datetime by Year: "Title:
Rollup with Datetime by Year"
SELECT CASE WHEN (Grouping (DATEPART(year,date_and_time)) = 1) THEN '- All Years -' ELSE CAST(DATEPART(year,CAST(SUM(CAST(DATEPART(year,date_and_time) as int))/count(*) as datetime))as varchar) END as 'Year',CAST(sum(attempt) as varchar) as 'Attempts', CAST(sum(success) as varchar) as 'Success', CAST(avg((success/attempt)*100) as varchar)+'%' as 'Success Rate', CAST(sum(failure) as varchar) as 'Failure', CAST(avg((failure/attempt)*100) as varchar)+'%' as 'Failure Rate', CAST(sum(cancelled) as varchar) as 'Cancelled', CAST(avg((cancelled/attempt)*100) as varchar)+'%' as 'Cancelled Rate', CAST(sum(macro_no_value) as varchar) as 'Macro', CAST(avg((macro_no_value/attempt)*100) as varchar)+'%' as 'Macro Rate' FROM apr_stats GROUP BY (DATEPART(year,date_and_time)) with ROLLUP ORDER BY (DATEPART(year,date_and_time))


www.svdeals.com super value deals