Click here to Skip to main content
15,886,769 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Question[Message Deleted] Pin
Bibhash Mishra12-Mar-09 3:41
Bibhash Mishra12-Mar-09 3:41 
AnswerRe: How to display world top cities time on my product Pin
Yusuf12-Mar-09 4:17
Yusuf12-Mar-09 4:17 
GeneralRe: How to display world top cities time on my product Pin
shawty_ds12-Mar-09 7:08
shawty_ds12-Mar-09 7:08 
GeneralRe: How to display world top cities time on my product [modified] Pin
Bibhash Mishra12-Mar-09 19:45
Bibhash Mishra12-Mar-09 19:45 
Questionproblem in login Pin
Manprit.bagga12-Mar-09 3:36
Manprit.bagga12-Mar-09 3:36 
AnswerRe: problem in login Pin
Yusuf12-Mar-09 4:19
Yusuf12-Mar-09 4:19 
QuestionRe: problem in login Pin
Manprit.bagga12-Mar-09 20:22
Manprit.bagga12-Mar-09 20:22 
QuestionExporting data to Excel from Datagrid Pin
rakeshs31212-Mar-09 3:13
rakeshs31212-Mar-09 3:13 
Hai all,

I am having a DataGrid, paging is true,at a time displaying 10 records.If i am exporting this datagrid data to excel,it is inserting all the records in the datagrid.Instead of that i want to insert only 10 recods.Code is below.I think the prob is with foreach loop in this code,how i should replace that
public void ExportDataToExcel(DataTable datatable, string[] Headers, string SourcePath, string DestinationPath)
	{
		int i, j;
		string strSourceTemplate = "";
		string strDestFileName = "";
		string strHeaders = "";
		string strRow = "";
      
		System.Data.OleDb.OleDbConnection objXlsCon = null;
		System.Data.OleDb.OleDbCommand objCmd;

		try
		{
			objXlsCon = new System.Data.OleDb.OleDbConnection();
//			if (Headers.Length != datatable.Columns.Count)
//			{
//				throw new Exception("Export Headers List and Table columns should be of same length");
//			}
			if (datatable.Rows.Count > 0)
			{
				strSourceTemplate = SourcePath;
				strDestFileName = DestinationPath;
				//if (File.Exists(strDestFileName))
				//{
				//    File.Delete(strDestFileName);
				//}
				System.IO.File.Copy(strSourceTemplate, strDestFileName);

				objXlsCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDestFileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;MAXSCANROWS=1;\";";
				objXlsCon.Open();
				objCmd = new System.Data.OleDb.OleDbCommand();
				objCmd.Connection = objXlsCon;

				//getting template headers
				for (i = 0; i < Headers.Length; i++)
				{
					strHeaders += Headers[i].ToString() + ",";
				}
				string s=datatable.Columns[0].ColumnName;
				int k=0;
				//getting values 
				foreach (DataRow drow in datatable.Rows)				{
					for (j = 0; j < datatable.Columns.Count; j++)
					{
						
						//if(Headers.Length > k)
						//if(drow[j].ToString() != "" && drow[j].ToString().Length<255)
						if(Headers.Length > k)
						{
							if(datatable.Columns[j].ColumnName == Headers[k].ToString())
							{
								if(drow[j].ToString() != "" )//&& drow[j].ToString().Length<255)
								{
									strRow += drow[j].ToString() + "','";
									
								}
								else
								{
									//							if(datatable.Columns[j].DataType.FullName == "System.String" || datatable.Columns[j].DataType.FullName == "System.DateTime")
									strRow +="-'"+",'";
									//							else
									//								strRow +="0"+",";

								}
								k++;
							}
							//k++;
						}
					}
                   
					objCmd.CommandText = "Insert into [Sheet1$] (" + strHeaders.Substring(0, strHeaders.Length - 1) + ") values ('" + strRow.Substring(0, strRow.Length - 3) + "')";
					objCmd.ExecuteNonQuery();
					strRow = "";
					j = 0;
					k=0;
				}

			}
		}
		catch (Exception ex)
		{
			throw ex;
		}
		finally
		{
			objCmd = null;
			objXlsCon.Close();
		}
       
	}

QuestionHow to get a message which user send from his mobile (reply to a message which is sent by application). Pin
rahul.net1112-Mar-09 2:58
rahul.net1112-Mar-09 2:58 
AnswerRe: How to get a message which user send from his mobile (reply to a message which is sent by application). Pin
Yusuf12-Mar-09 4:22
Yusuf12-Mar-09 4:22 
GeneralRe: How to get a message which user send from his mobile (reply to a message which is sent by application). Pin
rahul.net1112-Mar-09 4:52
rahul.net1112-Mar-09 4:52 
GeneralRe: How to get a message which user send from his mobile (reply to a message which is sent by application). Pin
Yusuf12-Mar-09 4:59
Yusuf12-Mar-09 4:59 
GeneralRe: How to get a message which user send from his mobile (reply to a message which is sent by application). Pin
shawty_ds12-Mar-09 7:13
shawty_ds12-Mar-09 7:13 
QuestionValidation is not working Pin
Member 299896912-Mar-09 2:48
Member 299896912-Mar-09 2:48 
AnswerRe: Validation is not working Pin
Yusuf12-Mar-09 2:58
Yusuf12-Mar-09 2:58 
GeneralRe: Validation is not working Pin
Member 299896912-Mar-09 3:30
Member 299896912-Mar-09 3:30 
AnswerRe: Validation is not working Pin
kumar_k50812-Mar-09 20:22
kumar_k50812-Mar-09 20:22 
GeneralRe: Validation is not working Pin
Member 299896912-Mar-09 20:48
Member 299896912-Mar-09 20:48 
GeneralRe: Validation is not working Pin
kumar_k50812-Mar-09 21:25
kumar_k50812-Mar-09 21:25 
QuestionJavascript not working after .net2 migration. Pin
imnotso#12-Mar-09 2:47
imnotso#12-Mar-09 2:47 
AnswerRe: Javascript not working after .net2 migration. Pin
Yusuf12-Mar-09 2:59
Yusuf12-Mar-09 2:59 
GeneralRe: Javascript not working after .net2 migration. Pin
imnotso#12-Mar-09 3:05
imnotso#12-Mar-09 3:05 
GeneralRe: Javascript not working after .net2 migration. Pin
Yusuf12-Mar-09 3:17
Yusuf12-Mar-09 3:17 
GeneralRe: Javascript not working after .net2 migration. Pin
imnotso#12-Mar-09 3:19
imnotso#12-Mar-09 3:19 
Questioncalling javascript function written in separate js file to validate contentpage controls which inherits masterpage Pin
Robymon12-Mar-09 2:16
Robymon12-Mar-09 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.