public bool deleteslabrecord(TSummeryReport deletetsr)
{
EntityManager.TSummeryReports.DeleteOnSubmit(EntityManager.TSummeryReports.Single(theItem=>theItem==deletetsr));
return SaveChanges();
}
Monday, February 28, 2011
Cannot remove an entity that has not been attached.
You will not be able to use attach on a context other then the original context the item was received on unless the entity has been serialized.
Wednesday, February 23, 2011
Merge dynamically create PDF at runtime
I played with this more than 3 days. Finally got the solution.
protected void Button1_Click(object sender, EventArgs e)
{
Guid uniqueid = Guid.NewGuid();
string uniqueidStr = uniqueid.ToString();
int cnt = 0;
string file = Server.MapPath("~/Admin/doc/invoice/Invoice.pdf");
string masterPDfFile = Server.MapPath("~/Admin/doc/invoice/result.pdf");
PdfCopyFields myPdfCopy = new PdfCopyFields(new FileStream(masterPDfFile, FileMode.Create));
while (cnt < 3)
{
PdfReader tmpReader = new PdfReader(file);
string tmpFilePath = Server.MapPath("~/Admin/doc/invoice/" +uniqueidStr+ cnt.ToString() + ".pdf");
FileStream tmppoutputFile = new FileStream(tmpFilePath, FileMode.Create);
PdfStamper tmpoutStamper = new PdfStamper(tmpReader, tmppoutputFile);
AcroFields testform = tmpoutStamper.AcroFields;
testform.SetField("T1","Lasantha");
tmpoutStamper.Close();
PdfReader nwpgReader = new PdfReader(tmpFilePath);
PdfTemplate page = tmpoutStamper.GetImportedPage(nwpgReader, 1);
myPdfCopy.AddDocument(nwpgReader);
cnt += 1;
}
myPdfCopy.Close();
cnt = 0;
while (cnt < 3)
{
string tmpFilePath = Server.MapPath("~/Admin/doc/invoice/" + uniqueidStr+cnt.ToString() + ".pdf");
System.IO.File.Delete(tmpFilePath);
cnt += 1;
}
PdfReader reader = new PdfReader(masterPDfFile);
string resultpath = Server.MapPath("~/Admin/doc/CustomerReports/result.pdf");
FileStream resultstr=new FileStream(resultpath,FileMode.Create);
PdfStamper result = new PdfStamper(reader, resultstr);
result.Close();
reader.Close();
System.IO.File.Delete(masterPDfFile);
}
Get DataTable From Linq query
Here code example
public DataTable ToDataTable(System.Data.Linq.DataContext ctx, object query)
{
if (query == null)
{
throw new ArgumentNullException("query");
}
IDbCommand cmd = ctx.GetCommand(query as IQueryable);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = (SqlCommand)cmd;
DataTable dt = new DataTable("sd");
try
{
cmd.Connection.Open();
adapter.FillSchema(dt, SchemaType.Source);
adapter.Fill(dt);
}
finally
{
cmd.Connection.Close();
}
return dt;
}
Split DataTable in to several DataTables
I achieved this requirement from this code snippet.
public DataTable[] getDataTables(DataTable tableToClone, int seperateVal, int val)
{
DataTable[] tables = new DataTable[val];
int count = 0;
int index = 0;
DataTable copyTable = null;
foreach (DataRow row in tableToClone.Rows)
{
if ((count++ % seperateVal) == 0)
{
copyTable = new DataTable();
copyTable = tableToClone.Clone();
tables[index] = copyTable;
index++;
}
copyTable.ImportRow(row);
}
return tables;
}
Monday, February 14, 2011
Invalid length for a Base-64 char array
This error gave me when i try to encrypt the query string. I solved this issue by http://forums.asp.net/t/1222829.aspx.
It worked fine. But now for some query string values it gives same error. The reason is there was a space character in the query string value. Then i replaced space character with "+". Its working now.
It worked fine. But now for some query string values it gives same error. The reason is there was a space character in the query string value. Then i replaced space character with "+". Its working now.
64-bit encoding does not work well with spaces in the string for some odd reason.
Tuesday, February 8, 2011
Label outside of the update panel is not update when event fire.
Place Label control inside another update panel.
Sunday, February 6, 2011
UpdatePanelAnimationExtender FadeIn FadeOut problem-page resize issue
Basically the problem is after animation worked page is not resize properly.what i did is put div tag name it as rightContainer and place the code whithing it what i need to update.Then Set the AnimationTarget="rightContainer".
Here the Code.
<FadeIn AnimationTarget="rightContainer" minimumOpacity=".6" />
<FadeOut AnimationTarget="rightContainer" minimumOpacity=".6" />
Here the Code.
<FadeIn AnimationTarget="rightContainer" minimumOpacity=".6" />
<FadeOut AnimationTarget="rightContainer" minimumOpacity=".6" />
Thursday, February 3, 2011
Wednesday, February 2, 2011
Get visible false asp Lable value from java script
<style>
.lbl{
display:none;
}
</style>
<asp:Lable ID="label1" runat="server" CssClass="lbl"/>
var val=document.getElementById("<%=label1.ClientID%>").innerHTML;
Subscribe to:
Posts (Atom)
How to Create Events Using Microsoft Graph API with Delegated Permissions and MSAL.js
Microsoft Graph API provides powerful capabilities to interact with Microsoft 365 services. In this guide, we’ll explore how to create calen...
-
I spent plenty of time for delving into this problem' depths. I can summarize the solution as follows: 1. Create The Entity Class (e.g...
-
Image upload with CKEditor. My latest issue was how to integrate CKFinder for image upload in CKEditor. Here the solution. 1. Download C...
-
I installed MVC4 latest version, but my app is using MVC3.0. The problem was on MVC version. Check MVC version of your app. Thanks Learn...