How to Delete a selected row in gridview using asp.net 2005 ?
How to Reset "Set as Start Page"
In a Web application project, VS 2005 allows you to right-click an .aspx page and choose "Set as Start Page." My question: is it possible to revert to the default behavior, where the start page will be whichever page you are currently editing?
Passing Value to Local Report
In VB 2005, I want to pass a value from Form1 to Report(Form2 Report1.RDLC ). Could some one help me pls.
Refreshing Property Window?
DataTable Update
Hello, I have been working on this for a while and it is driving me insane, so any help would really be appreciated.
I send in to the below method a DataTable that has been edited through a dataGridView. I then get the original DataTable, set the original DataTable to equal the changed Datatable and then update the new Table. The problem I have is the Parameters I set in the BuildCommands method are always null.
Thanks for the help
public void updateDt(DataTable dt)
{
SqlDataAdapter dataAdapter = new SqlDataAdapter();
DataTable dtTempDataTable = new DataTable();
string SqlStmt = "SELECT * testId, testField FROM TEST";
try
{
string commandstring = SQLStmt;dataAdapter = new SqlDataAdapter(commandstring, DatabaseConnection); BuildCommands(dataAdapter);
dataAdapter.Fill(dtTempDataTable);
//fills with 4 rows dtTempDataTable = dt, //set new dt to dt with user changes dtTempDataTable.AcceptChanges();
dataAdapter.Update(dtTempDataTable); //doesnt do a thing
}
catch { }
finally { }
}
private void BuildCommands(SqlDataAdapter dataAdapter)
{
SqlConnection connection = (SqlConnection)dataAdapter.SelectCommand.Connection; SqlParameter workParam = null;
string query = "Update TEST Set testField = @testField WHERE testid= @testid";
dataAdapter.UpdateCommand = new SqlCommand(query, connection);
workParam = dataAdapter.UpdateCommand.Parameters.Add("@testField", SqlDbType.BigInt);
workParam.SourceColumn = "testfield";
workParam = dataAdapter.UpdateCommand.Parameters.Add("@testid", SqlDbType.BigInt); workParam.SourceColumn = "testId";
}
Make "Export to Excel" always open excel in a separate Window
Export to Excel in ASP.NET is a very common feature, which I'm sure everyone who has worked in ASP.NET would have had the chance to implement. Whenever we choose the Export to Excel option from our Application, a dialog box pops us with the option to Open or to Save.
By chance if the user checks off the option "Always ask before opening this type of file" that is shown in the dialog box, from next time the user will not be able to see the dialog box. Instead, the excel file opens up in the same window.
To set back this option, the following steps can be followed:
1. Go to Windows Explorer.
2. On the Tools menu, click Folder Options, and then click on the File Types tab.
3. From the Registered file types list box, select the XLS extension, and then click Advanced.
4. In the Edit File Type dialog box, set the Confirm open after download to selected.
5. Make sure the Browse in same window option is not selected, and then click OK.
The above steps will make sure that we get the dialog box as shown above. However, since this is an option set at the client computer, these steps cannot be mandated to be followed in every computer that browses the application.So, from the code level, we must make sure that the excel file is opened in a separate window. One possible option for this is to Save the file to the web server, and then open the file in a separate window.
The code for this is given below:
private void ExportToExcel(DataGrid dgExport)
{
try
{
string strFileName = String.Empty, strFilePath= String.Empty;
strFilePath = Server.MapPath(@"../Excel/") + "ExcelFileName" + ".xls";
if (File.Exists(strFilePath))
{
File.Delete(strFilePath);
}
System.IO.StringWriter oStringWriter =new StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
StreamWriter objStreamWriter;
string strStyle =@" .text { mso-number-format:\@; } ";
objStreamWriter = File.AppendText(strFilePath);
dgExport.RenderControl(oHtmlTextWriter);
objStreamWriter.WriteLine(strStyle);
objStreamWriter.WriteLine(oStringWriter.ToString());
objStreamWriter.Close();
string strScript = "
";
if(!Page.IsStartupScriptRegistered("clientScript"))
{
Page.RegisterStartupScript("clientScript", strScript);
}
}
catch(Exception)
{
//Handle Exception
}
}
In the above method, the file is saved to the Web Server inside the folder "Excel". Of course, this folder must have write permissions for the user. But it will definitely ensure that the excel file is opened in a new window in the client computer.
Cheers.
Export to Excel in ASP.NET is a very common feature, which I'm sure everyone who has worked in ASP.NET would have had the chance to implement. Whenever we choose the Export to Excel option from our Application, a dialog box pops us with the option to Open or to Save.
By chance if the user checks off the option "Always ask before opening this type of file" that is shown in the dialog box, from next time the user will not be able to see the dialog box. Instead, the excel file opens up in the same window.
To set back this option, the following steps can be followed:
1. Go to Windows Explorer.
2. On the Tools menu, click Folder Options, and then click on the File Types tab.
3. From the Registered file types list box, select the XLS extension, and then click Advanced.
4. In the Edit File Type dialog box, set the Confirm open after download to selected.
5. Make sure the Browse in same window option is not selected, and then click OK.
The above steps will make sure that we get the dialog box as shown above. However, since this is an option set at the client computer, these steps cannot be mandated to be followed in every computer that browses the application.So, from the code level, we must make sure that the excel file is opened in a separate window. One possible option for this is to Save the file to the web server, and then open the file in a separate window.
The code for this is given below:
private void ExportToExcel(DataGrid dgExport)
{
try
{
string strFileName = String.Empty, strFilePath= String.Empty;
strFilePath = Server.MapPath(@"../Excel/") + "ExcelFileName" + ".xls";
if (File.Exists(strFilePath))
{
File.Delete(strFilePath);
}
System.IO.StringWriter oStringWriter =new StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
StreamWriter objStreamWriter;
string strStyle =@" .text { mso-number-format:\@; } ";
objStreamWriter = File.AppendText(strFilePath);
dgExport.RenderControl(oHtmlTextWriter);
objStreamWriter.WriteLine(strStyle);
objStreamWriter.WriteLine(oStringWriter.ToString());
objStreamWriter.Close();
string strScript = "
";
if(!Page.IsStartupScriptRegistered("clientScript"))
{
Page.RegisterStartupScript("clientScript", strScript);
}
}
catch(Exception)
{
//Handle Exception
}
}
In the above method, the file is saved to the Web Server inside the folder "Excel". Of course, this folder must have write permissions for the user. But it will definitely ensure that the excel file is opened in a new window in the client computer.
Cheers.
Wrap an EXE file
Hi,
I have a requirement to 'wrap' an EXE file so it cannot be accessed by unathorized user. I have created a simple application which stores username database and generate Log. I have thought to decrypt the EXE through my application, so it can only be accessed through my application and encrypt it right away when the user logs-off from my application. That way the EXE will not be able to be accessed without my Application. unfortunately, I do not know how to do this. I've used ClassMD5.getHash function to encrypt/decrypt password into database, but I'm afraid it cannot be used to encrypt EXE since it only hold String. *the EXE file itself is 3,7MB and I do not have the source code.
do you guys know a way to encrypt/decrypt the EXE without third-party program?
or maybe you guys have thought of an alternative way, such as: create windows user? folder permission , etc
Calling MDI Child Methods from MDI Parent Form
Dear All,
I require your assistance in the following:
I have a main MDI Form, frmMain (Parent)
This form has a Menu which has Save, Add Delete and other commands
I want that if someone click on this save menu item... then... save method of my active child form is run. ( frmEmployee )
Obviously i will have to first find which form is active then will see whether this form has any save method or not!
I will be very very thankful and appreciate any help .... any technique and ways to do it... please explain with examples if possibles ... please!!!
Session c#
Hi Can anybody tell me how to use session ? I have a products page and i only want the logged users to see that page. I have table where i have stored the user_name and password ..
can anyone help by sending the code ?
on error resume next in c# Options
Hi,
We have on error resume next option in vb language but we dont have that in c#.
I just want to do the same kind of functionality in c#.
Any help is really appreciated.
CS0246 (problem with user-defined namespace), C#.NET 2.0
C# Online.NET Options
FOR IMMEDIATE RELEASE
First Wiki-based Online C# and .NET Reference at C# Online.NET
Dallas, TX — A new concept in online references for Microsoft .NET programming languages is being pioneered by C# Online.NET–a new wiki-based, online C# and .NET reference. C# Online.NET offers documentation, tutorials, and C# source code examples for .NET languages beginning with the C# language. “Compared to Java,” says Will Wagers, founder of C# Online.NET, “there is a dearth of online C# help.”
C# Online.NET is enlisting the aid of volunteer contributors to write articles, tutorials, and C# code snippets (ready-to-use fragments of C# source code). Offerings will target all C# programmers and developers from beginner to architect. Wiki software allows virtually anyone with an Internet connection to edit, view, and write documentation using their Web browser. “The advantage of using open source wiki software is that we can harness the energies of C# developers worldwide to create a mega-resource for the C# community.”
site: http://wiki.csharp-online.net/
ASP .NET 2.0 Visual Studio 2005 - Deploying - No DLLs
The application ran normally, and I expected that first use would have triggered a compilation of the website, but there are no DLL files in the Bin folder, like when I publish with Visual Studio.
How does this work? How can I still use copy to deploy, and get a compiled website?