Click here to Skip to main content
15,896,304 members
Home / Discussions / C#
   

C#

 
QuestionRe: How to save text from TextBox2 as UTF-16 (Unicode), and not as UTF-8 - C# Pin
Richard MacCutchan21-Dec-14 22:29
mveRichard MacCutchan21-Dec-14 22:29 
AnswerRe: How to save text from TextBox2 as UTF-16 (Unicode), and not as UTF-8 - C# Pin
Member 1041097223-Dec-14 0:32
Member 1041097223-Dec-14 0:32 
GeneralRe: How to save text from TextBox2 as UTF-16 (Unicode), and not as UTF-8 - C# Pin
Richard MacCutchan23-Dec-14 1:41
mveRichard MacCutchan23-Dec-14 1:41 
AnswerRe: How to save text from TextBox2 as UTF-16 (Unicode), and not as UTF-8 - C# Pin
Rob Philpott22-Dec-14 0:58
Rob Philpott22-Dec-14 0:58 
QuestionEncoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250") Pin
Member 1041097221-Dec-14 9:38
Member 1041097221-Dec-14 9:38 
AnswerRe: Encoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250") PinPopular
Garth J Lancaster21-Dec-14 10:09
professionalGarth J Lancaster21-Dec-14 10:09 
GeneralRe: Encoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250") Pin
Member 1041097221-Dec-14 20:15
Member 1041097221-Dec-14 20:15 
AnswerRe: Encoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250") Pin
Amresh Bahadur Singh21-Dec-14 23:23
Amresh Bahadur Singh21-Dec-14 23:23 
Questionsending SMS using SMPP in C# Pin
Jassim Rahma20-Dec-14 22:59
Jassim Rahma20-Dec-14 22:59 
AnswerRe: sending SMS using SMPP in C# Pin
DamithSL20-Dec-14 23:25
professionalDamithSL20-Dec-14 23:25 
SuggestionRe: sending SMS using SMPP in C# Pin
Kornfeld Eliyahu Peter20-Dec-14 23:28
professionalKornfeld Eliyahu Peter20-Dec-14 23:28 
Suggestionimplementation suggesion for a customized list page Pin
NowYouSeeMe18-Dec-14 18:37
NowYouSeeMe18-Dec-14 18:37 
GeneralRe: implementation suggesion for a customized list page Pin
syed shanu18-Dec-14 19:16
professionalsyed shanu18-Dec-14 19:16 
GeneralRe: implementation suggesion for a customized list page Pin
BillWoodruff19-Dec-14 3:57
professionalBillWoodruff19-Dec-14 3:57 
GeneralRe: implementation suggesion for a customized list page Pin
Amresh Bahadur Singh21-Dec-14 23:34
Amresh Bahadur Singh21-Dec-14 23:34 
QuestionCode Design - Event call, Catch exceptions or not? Pin
GerVenson18-Dec-14 12:38
professionalGerVenson18-Dec-14 12:38 
AnswerRe: Code Design - Event call, Catch exceptions or not? Pin
Eddy Vluggen19-Dec-14 7:14
professionalEddy Vluggen19-Dec-14 7:14 
Questionc# string param passing vs vb.net Pin
SepPax18-Dec-14 10:46
SepPax18-Dec-14 10:46 
GeneralRe: c# string param passing vs vb.net Pin
PIEBALDconsult18-Dec-14 11:39
mvePIEBALDconsult18-Dec-14 11:39 
AnswerRe: c# string param passing vs vb.net PinPopular
Dave Kreskowiak18-Dec-14 12:49
mveDave Kreskowiak18-Dec-14 12:49 
GeneralRe: c# string param passing vs vb.net Pin
SepPax18-Dec-14 19:47
SepPax18-Dec-14 19:47 
GeneralRe: c# string param passing vs vb.net Pin
Dave Kreskowiak19-Dec-14 2:12
mveDave Kreskowiak19-Dec-14 2:12 
GeneralRe: c# string param passing vs vb.net Pin
SepPax19-Dec-14 3:22
SepPax19-Dec-14 3:22 
GeneralRe: c# string param passing vs vb.net Pin
SepPax19-Dec-14 5:07
SepPax19-Dec-14 5:07 
Questionfile not uploading Help.... Pin
Member 1132096518-Dec-14 5:47
Member 1132096518-Dec-14 5:47 
When i chose a file to up load it says
Object reference not set to an instance of an object.
.




C#
protected void DocumentUpload_OnFileUploadComplete(object sender, FileUploadCompleteEventArgs e)
      {
          if (!e.UploadedFile.IsValid) return;

          GridViewDetailRowTemplateContainer container = ((Control)sender).NamingContainer as GridViewDetailRowTemplateContainer;
          Int32 index = container.VisibleIndex;

          var orderId = Convert.ToInt32(ViewOrdersGridView.GetRowValues(index, ViewOrdersGridView.KeyFieldName));
          var fileNumber = ViewOrdersGridView.GetRowValues(index, ElsaConstants.FileNumber).ToString();
          var userId = Convert.ToInt32(Session[ElsaConstants.UserId]);
          string directory = ConfigurationManager.AppSettings[ElsaConstants.UploadDirectory];
          if (!Directory.Exists(directory))
          {
              Directory.CreateDirectory(directory);
          }

          string fileType = Path.GetExtension(e.UploadedFile.FileName);
          string fileName = e.UploadedFile.FileName.Replace(fileType, string.Format("_{0}{1}", fileNumber, fileType));
          string resultFilePath = directory + fileName;
          e.UploadedFile.SaveAs(resultFilePath, true);//MapPath

          using (var context = new ELSAEntities())
          {
              var document = new Document
              {
                  OrderId = orderId,
                  DocumentPath = fileName,
                  DateCreated = DateTime.Now,
                  CreatedBy = userId
              };

              context.Document.Add(document);
              context.SaveChanges();
          }
      }


modified 18-Dec-14 12:16pm.

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.