Samples @delicious
Samples @microsoft
9 hours ago
Information Sharing, Technical Articles. You can find solutions, best precticies for ASP.net application. More knowledge sharing on C#, AJAX, SQL, .Net Framework, OOPs Concepts, SQL Server 2005, SQL Server 2000, Programming.
protected void Application_EndRequest(object sender, EventArgs e)
{
if (Response.RedirectLocation != null && Response.RedirectLocation.Contains("ReturnUrl"))
{
Response.RedirectLocation = string.Format("{0}ReturnUrl={1}",
Response.RedirectLocation.Remove(Response.RedirectLocation.IndexOf("ReturnUrl")
, (Request.RawUrl.Contains("ReturnUrl") ?
Request.RawUrl.Substring(Request.RawUrl.IndexOf("ReturnUrl") + 10)
: Request.RawUrl
)
));
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Features
{
public static class Extensions
{
public static int ToInt32(this string s)
{
return Int32.Parse(s);
}
}
class Program
{
static void Main(string[] args)
{
string strTest = "1";
Console.WriteLine(strTest.ToInt32()); //Will print 1
}
}
}
(this string s)
UserID CaseID CaseNumber ClientID
----------- ----------- ----------- -----------
80 216 1087 247
80 216 1087 248
80 216 1087 249
80 216 1087 250
80 216 1087 251
80 216 1087 252
80 276 1140 328
80 277 1143 329
80 347 1191 438
80 348 1192 439
SELECT UserID, C.CaseID, CaseNumber, ClientID,
'ClientId' + CAST(
RANK() OVER (
PARTITION BY C.CaseID, CaseNumber
ORDER BY ClientID) AS VARCHAR(10)) ClientIdListing
FROM [Case] C, CaseClient CC
WHERE C.CaseId = CC.CaseID AND USerID = 80
UserID CaseID CaseNumber ClientID ClientIdListing
----------- ----------- ----------- ----------- ------------------
80 216 1087 247 ClientId1
80 216 1087 248 ClientId2
80 216 1087 249 ClientId3
80 216 1087 250 ClientId4
80 216 1087 251 ClientId5
80 216 1087 252 ClientId6
80 276 1140 328 ClientId1
80 277 1143 329 ClientId1
80 347 1191 438 ClientId1
80 348 1192 439 ClientId1
SELECT * FROM
(SELECT UserID, C.CaseID, CaseNumber, ClientID, 'ClientId'
+ CAST(RANK() OVER (PARTITION BY C.CaseID, CaseNumber
ORDER BY ClientID)
AS VARCHAR(10)) ClientIdListing
FROM [Case] C, CaseClient CC
WHERE C.CaseId = CC.CaseID
AND USerID = 80) P
PIVOT
(MAX(ClientID) FOR ClientIdListing IN
(ClientID1, ClientID2, ClientID3, ClientID4, ClientID5, ClientID6)
) AS Clients
UserID CaseID CaseNumber ClientID1 ClientID2 ClientID3 ClientID4 ClientID5 ClientID6
----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- -----------
80 216 1087 247 248 249 250 251 252
80 276 1140 328 NULL NULL NULL NULL NULL
80 277 1143 329 NULL NULL NULL NULL NULL
80 347 1191 438 NULL NULL NULL NULL NULL
80 348 1192 439 NULL NULL NULL NULL NULL
string strConn = "Data Source=[DATASOURCE];Initial Catalog=[DATABASE];User ID=[UID];Password=[PWD];MultipleActiveResultSets=true";
string strSql = "select DoctorId, PatientId from [Patient] where DoctorId = {0}";
string strOutput = "<br/>DoctorId:{0} - PatientId{1}";
using (SqlConnection con = new SqlConnection(strConn))
{
//Opening Connection
con.Open();
//Creating two commands form current connection
SqlCommand cmd1 = con.CreateCommand();
SqlCommand cmd2 = con.CreateCommand();
//Set the comment type
cmd1.CommandType = CommandType.Text;
cmd2.CommandType = CommandType.Text;
//Setting the command text to first command
cmd1.CommandText = "select distinct DoctorId from [Doctor] where HospitalId = 8";
//Execute the first command
IDataReader idr1 = cmd1.ExecuteReader();
while (idr1.Read())
{
//Read the first doctor from data source
int intDoctorId = idr1.GetInt32(0);
//create another command, which get patients of doctor
cmd2.CommandText = string.Format(strSql, intDoctorId);
//Execute the reader
IDataReader idr2 = cmd2.ExecuteReader();
while (idr2.Read())
{
//Read the doctor and patient
Response.Write(string.Format(strOutput, idr2.GetInt32(0), idr2.GetInt32(1)));
}
//Dont forgot to close second reader, this will just close reader not connection
idr2.Close();
}
}
This is simple delegate with out any parameter. The click event of Login button will be handled by function ValidateUser of some class.
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
btnLogin.Click += delegate { objClass.ValidateUser(); };
}
As its function without name, you can also write your code there.
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.btnLogin.Click += delegate(object sender, EventArgs args) { presenter.ValidateUser(); };
}
protected override void OnInit(EventArgs e)That is the basic idea.
{
base.OnInit(e);
rptUserList.ItemCommand += delegate(object source, RepeaterCommandEventArgs ee)
{
Console.Write(int.Parse(ee.CommandArgument.ToString()));
objClass.GetDetailsById(int.Parse(ee.CommandArgument.ToString()));
//display the details
Console.Write(objClass.Name);
};
}
| Blog.Feed() | : |
|
| Blog.PageCounter() | : |
|
| Me.Resume() | : | Imran Bhadelia |
| Me.Consult() | : | Click Here |