|
After the insert line try to use
Response.Redirect(Request.Url.PathAndQuery)
HTH
|
|
|
|
|
Thanks for your response.
This is not working.
Here i am not directly inserting the record into the Grid. First i am writing that record to a CSV File.From that I am constructing a datatable and giving that datatable as a datasource to the Grid.
THis is the requirement of the project.
Ramu
|
|
|
|
|
Ramu.M wrote: When user clicks the button multiple times (continously)
You can prevent this by disabling the button.. If the users click the button, you can disable it by using Javascript. After the processing is done, you can re-enabled it.
|
|
|
|
|
|
I am using asp.net+vb.net
I want to export datas from sqlserver to excel.I wrote code for that.My it display in the internet explorer same page. I want to display in another page and want to set only print button for that page.
The code i wrote is given below.
*****************
Private Sub BindReport()
If Session("Rep") Is Nothing Then
Dim ConnInfo As New ConnectionInfo
With ConnInfo
.ServerName = "User1"
.DatabaseName = "IMS"
.UserID = "sa"
.Password = ""
End With
Dim rep As New ReportDocument
rep.Load(Server.MapPath("Crystalreport2.rpt"))
Me.CrystalReportViewer1.ReportSource = rep
Dim RepTbls As Tables = rep.Database.Tables
For Each RepTbl As Table In RepTbls
Dim RepTblLogonInfo As TableLogOnInfo = RepTbl.LogOnInfo
RepTblLogonInfo.ConnectionInfo = ConnInfo
RepTbl.ApplyLogOnInfo(RepTblLogonInfo)
Next
Session("Rep") = rep
End If
Me.CrystalReportViewer1.ReportSource = Session("Rep")
Me.CrystalReportViewer1.DataBind()
End Sub
**************************
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindReport()
Me.CrystalReportViewer1.ShowFirstPage()
End If
end sub
******************************
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
crReportDocument = New ReportDocument()
crReportDocument.Load(Server.MapPath("crystalreport2.rpt"))
Fname = "C:\exports\" & Session.SessionID.ToString & ".xls"
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
crReportDocument.Export()
Dim oStream As New MemoryStream
oStream = crReportDocument.ExportToStream(ExportFormatType.Excel)
oStream = crReportDocument.ExportToStream(ExportFormatType.Excel)
report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.ExcelRecord)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.BinaryWrite(oStream.ToArray())
Response.End()
end sub
and also i want to display it in word how can i do the pls give code also.
|
|
|
|
|
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Clear()
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.xls", "tmc.xls"))
'Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "kumaresh"))
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
'Response.ContentType = "application/ms-excel"
Response.ContentType = "application/"
Dim stringWrite As New StringWriter()
Dim htmlWrite As New HtmlTextWriter(stringWrite)
GridView1.RenderBeginTag(htmlWrite)
GridView1.RenderControl(htmlWrite)
GridView1.RenderEndTag(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
|
|
|
|
|
i am using crystal report in this code.My program working properly but i want to display only print button in toolbar not other toolbar buttons.
I also want to export this crystal report details in word.
How can i do this.Pls help
|
|
|
|
|
Is the data in a table with datatype image is editable in database.When i stored an image into db,and try to modify it an error occurs that the cell is not editable.Why this occur.
|
|
|
|
|
SreejithAchutan wrote: Is the data in a table with datatype image is editable in database.
Not editable. You can't edit it manually. You probably need to use the SQL statement..
|
|
|
|
|
I tried it using sql update command itself ,then also an exception of string or binary data truncated is occured.
|
|
|
|
|
Can you please show us the code for updating the image column? so, we can figure out what wrong in your code?
|
|
|
|
|
public void UpdateUnitDetails(int UnitId, string UnitName, string UnitShortName, string Location, string UnitLogoPath, string UnitStream, string MaxStudentsPerClass, string LastModifiedByUser)
{
string sqlstatement;
Boolean isUpdated;
try
{
sqlstatement = "UPDATE Units SET UnitName='" + UnitName + "',UnitShortName='" + UnitShortName + "',Location='" + Location + "',UnitLogoPath='" + UnitLogoPath + "',UnitStream='" + UnitStream + "',MaxStudentsPerClass='" + MaxStudentsPerClass + "',LastModifiedByUser='" + LastModifiedByUser + "' WHERE UnitId='" + UnitId + "'";
isUpdated = dbtObj.ExecuteSqlCmd(sqlstatement);
}
finally
{
}
}
protected void btnModify_Click(object sender, EventArgs e)
{
MembershipUser MU;
int UnitId;
string ID;
try
{
MU = Membership.GetUser();
string LastModifiedByUser = MU.UserName;
ID = Gdv_Unit_List.SelectedDataKey.Value.ToString();
UnitId = int.Parse(ID);
Gdv_Unit_List.Columns[0].Visible = true;
string logo = insunit.UploadUnitLogo(UnitId);
if (logo != "")
{
insunit.UpdateUnitDetails(UnitId, Txt_UnitName.Text, Txt_ShortName.Text, Txt_Location.Text, Upload_Logo.FileName.ToString(), DdlStreamList.SelectedItem.ToString(), TxtStdperClass.Text, LastModifiedByUser);
}
else
insunit.UpdateUnitDetails(UnitId, Txt_UnitName.Text, Txt_ShortName.Text, Txt_Location.Text, Upload_Logo.FileName.ToString(), DdlStreamList.SelectedItem.ToString(), TxtStdperClass.Text, LastModifiedByUser);
Gdv_Unit_List.Columns[0].Visible = false;
BindGrid();
}
finally
{
}
}
Thsi is the code .
|
|
|
|
|
SreejithAchutan wrote: public void UpdateUnitDetails(int UnitId, string UnitName, string UnitShortName, string Location, string UnitLogoPath, string UnitStream, string MaxStudentsPerClass, string LastModifiedByUser)
{
string sqlstatement;
Boolean isUpdated;
try
{
sqlstatement = "UPDATE Units SET UnitName='" + UnitName + "',UnitShortName='" + UnitShortName + "',Location='" + Location + "',UnitLogoPath='" + UnitLogoPath + "',UnitStream='" + UnitStream + "',MaxStudentsPerClass='" + MaxStudentsPerClass + "',LastModifiedByUser='" + LastModifiedByUser + "' WHERE UnitId='" + UnitId + "'";
isUpdated = dbtObj.ExecuteSqlCmd(sqlstatement);
}
finally
{
}
}
What is the code for updating the image? Are you updating the path of image (string) or image (bytes)?
The code below is for updating the image column ... (Note: I typed just like that so you may need to fix some syntax errors but you can get the idea from that code. )
<br />
byte[] img = <br />
SqlCommand update = new SqlCommand("UPDATE Person SET ImageColumn = @image<br />
WHERE personalID = " + pID, con);<br />
<br />
SqlParameter imageParameter = update.Parameters.Add("@image",<br />
SqlType.Image);<br />
imageParameter.Value = img;<br />
imageParameter.Size = img.Length;
Hope it helps..
|
|
|
|
|
OT: Your code for the sql statement is a sql injection attack waiting to happen. It's best not to use string concatenation, but rather use parameterized queries for safer coding. Read the SQL Injection Attack article on this site by Colin Mackay.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Actually we can modify obnly once .if we try to modify next time then an error had occured.What is the reason."The error is String or Binary is truncated".Is this is due to database design.lz help me
|
|
|
|
|
I cahnge the image into byte and save and also when modifying the image will be converted.But the pbm occurs only once we can modify the data.when we tried to modify next time an exception occurs.What is the pbm is the pbm in table design.plz help me.
|
|
|
|
|
CODE UNDER ROW BOUND DATA IN GRIDVIEW
Button b = (Button)e.Row.FindControl("update");
if (b != null)
{
string str = ChangeDateFormat(DataBinder.Eval(e.Row.DataItem, "indate").ToString());
b.Attributes.Add("onclick", "return abc(" + str.ToString() + ");");
}
CODE IN THE JAVA SCRIPT FUNCTION
function abc(s)
{
alert(s);
return false;
}
Function Defenition
public string ChangeDateFormat(string t)
{
string dat = "";
DateTime datformat;
if (DateTime.TryParse(t, out datformat))
{
dat = datformat.ToString("dd/MM/yyyy");
return dat;
}
return dat;
}
now when i click at the upDATE BUTTON TO CHECK THE VALUE IT GIVES
6576576575757657657
ACTUALLY IT SHOULD GIVE THE DATE IN DD/MM/YYYY FORMAT 12/12/2000.
I HAVED DEBUGGED THE CODE .IT IS SENDIG THE ACCURATE DATE.
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Sonia Gupta wrote: I HAVED DEBUGGED THE CODE .IT IS SENDIG THE ACCURATE DATE.
DON'T SHOUT. OKAY??
Sonia Gupta wrote: I HAVED DEBUGGED THE CODE .IT IS SENDIG THE ACCURATE DATE.
So, what? Are you asking the question or just wanted to let us know that you have debugged the code?
|
|
|
|
|
Sir, if u don;t want to reply , fine , No Problem , Y r u behaving so rudely.
All i am trying to say , is that , up to this level , i have achieved a particular task , now i am unable to solve it further.
and Sir , as far as the duplicate post is concerned , sir it is lying in the third page .
If u are so concerned with these duplicate posts , sir , i am very eager for ur reply , there in the third page
Thank You Sir
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Sonia Gupta wrote: Sir, if u don;t want to reply , fine , No Problem , Y r u behaving so rudely.
Sonia, As you are in this forum for long time, you might probably read my reply for other.. So, you might know how I reply.. but you are the one who started shouting in our forum.. Typing in capital is considered as very rude.. but you are asking the question in very rude way..
Sonia Gupta wrote: sir it is lying in the third page .
I can understand this. but what I want to say is that you should at least reply his post.. Because he is also the one who is trying to help you..
So,
- Don't shout here (typing in capital letters)
- Don't forget to reply any post that replied to your question..
Thank you too..
modified on Friday, January 04, 2008 3:26:05 AM
|
|
|
|
|
Michael Sync wrote: but you are the one who start shouting in our forum
What's the meaning of this line.Have u purchased the code project site ?????????????
Congratulations!!!!!!!!!
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Sonia Gupta wrote: Have u purchased the code project site ?????????????
Did I say that I bought CP? What I was saying is that you are the one who started shouting here. Oh, btw, what is the difference between "my" and "our"?
|
|
|
|
|
Sir, May i advice u that whenever u feel tired , please take some rest or have some outing.
Be Happy
Cheers....
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Okay. Sonia. Thanks. Good luck!
|
|
|
|
|