Click here to Skip to main content
16,007,504 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: ASP.Net with Apache Pin
kavithakcross19-Nov-08 20:12
kavithakcross19-Nov-08 20:12 
GeneralRe: ASP.Net with Apache Pin
Parwej Ahamad19-Nov-08 21:53
professionalParwej Ahamad19-Nov-08 21:53 
GeneralRe: ASP.Net with Apache Pin
kavithakcross19-Nov-08 22:43
kavithakcross19-Nov-08 22:43 
QuestionNeed help with IIS authentication Pin
Rajeevg19-Nov-08 18:29
Rajeevg19-Nov-08 18:29 
QuestionReport Viewer Pin
kenexcelon19-Nov-08 14:19
kenexcelon19-Nov-08 14:19 
AnswerRe: Report Viewer Pin
Samer Aburabie19-Nov-08 14:44
Samer Aburabie19-Nov-08 14:44 
GeneralRe: Report Viewer Pin
kenexcelon20-Nov-08 14:52
kenexcelon20-Nov-08 14:52 
Questionexport to excel from asp.net Pin
Member 141625419-Nov-08 13:16
Member 141625419-Nov-08 13:16 
Ok, here is what I really what to do. How to I hide the DistributorID when loaded but display it when the excel file is exported.

You might be thinking why don't I delete it form the page_load then, well I can't do that cause then my cells will not match up to the database

to the LinkButton1_Click event





using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;



public partial class manager_view_distributors : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

AlternaDB.MarketingDataContext db = new AlternaDB.MarketingDataContext();



var products = from p in db.Distributors



select new { p.DistributorID, Company_Name = p.CompanyName, Address = p.AddressLine1, p.City, Zip_Code = p.ZipCode, p.State, First_Name = p.Contact1FirstName, Last_Name = p.Contact1LastName, Area_Code = p.Contact1WorkAreaCode, Phone = p.Contact1WorkNumber, Num_Stores = p.NumStores, Num_DSC = p.NumDsc };



GridView1.DataSource = products;

GridView1.DataBind();



}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

{



GridView1.PageSize = Int32.Parse(DropDownList1.SelectedValue); this.GetData();

}

private void GetData()

{

GridView1.DataBind();



}



protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)

{



GridView1.PageIndex = e.NewPageIndex;



this.GetData();

}

protected void LinkButton1_Click(object sender, EventArgs e)

{

if (this.rdoBtnListExportOptions.SelectedIndex == 1)

{

// the user wants all rows exported, turn off paging

// and rebing the grid before sending it to the export

// utility

ExportExcelColumns();

this.GridView1.PageSize = 1000000;

GridView1.DataBind();

}

else if (this.rdoBtnListExportOptions.SelectedIndex == 2)

{

// the user wants just the first 100,

// adjust the PageSize and rebind

ExportExcelColumns();

this.GridView1.PageSize = 100;

GridView1.DataBind();





}

//Current Page export

else if (this.rdoBtnListExportOptions.SelectedIndex == 0)

{

ExportExcelColumns();

GridView1.DataBind();



}

GridViewExportUtil.Export("Customers.xls", this.GridView1);





}



private void ExportExcelColumns()

{

// pass the grid that for exporting ...

AlternaDB.MarketingDataContext db = new AlternaDB.MarketingDataContext();

var dist = from d in db.Distributors

select new

{

d.DistributorID,

AccountType = SalonForm.DistAccountType.GetDistAccountTypeByValue((int)d.AccountType),

AccountStatus = SalonForm.AccountStatus.GetAccountStatusByValue((int)d.AccountStatus),

d.CompanyName,

d.AddressLine1,

d.AddressLine2,

d.City,

d.State,

d.Country,

d.ZipCode,

d.Territory,

d.NumDsc,

d.NumStores,

d.Website,

Contact1Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact1Type),

d.Contact1FirstName,

d.Contact1LastName,

d.Contact1Email,

d.Contact1WorkIntlPrefix,

d.Contact1WorkAreaCode,

d.Contact1WorkNumber,

d.Contact1WorkExtension,

d.Contact1CellIntlPrefix,

d.Contact1CellAreaCode,

d.Contact1CellNumber,

d.Contact1CellExtension,

d.Contact1ReceiveEnews,

Contact2Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact2Type),

d.Contact2FirstName,

d.Contact2LastName,

d.Contact2Email,

d.Contact2WorkIntlPrefix,

d.Contact2WorkAreaCode,

d.Contact2WorkNumber,

d.Contact2WorkExtension,

d.Contact2CellIntlPrefix,

d.Contact2CellAreaCode,

d.Contact2CellNumber,

d.Contact2CellExtension,

d.Contact2ReceiveEnews,

Contact3Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact3Type),

d.Contact3FirstName,

d.Contact3LastName,

d.Contact3Email,

d.Contact3WorkIntlPrefix,

d.Contact3WorkAreaCode,

d.Contact3WorkNumber,

d.Contact3WorkExtension,

d.Contact3CellIntlPrefix,

d.Contact3CellAreaCode,

d.Contact3CellNumber,

d.Contact3CellExtension,

d.Contact3ReceiveEnews,

Contact4Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact4Type),

d.Contact4Firstname,

d.Contact4LastName,

d.Contact4Email,

d.Contact4WorkIntlPrefix,

d.Contact4WorkIntlAreaCode,

d.Contact4WorkNumber,

d.Contact4WorkExtension,

d.Contact4CellIntlPrefix,

d.Contact4CellAreaCode,

d.Contact4CellNumber,

d.Contact4CellExtension,

d.Contact4ReceiveEnews,

Contact5Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact5Type),

d.Contact5FirstName,

d.Contact5LastName,

d.Contact5Email,

d.Contact5WorkIntlPrefix,

d.Contact5WorkAreaCode,

d.Contact5WorkNumber,

d.Contact5WorkExtension,

d.Contact5CellIntlPrefix,

d.Contact5CellAreaCode,

d.Contact5CellNumber,

d.Contact5CellExtenstion,

d.Contact5ReceiveEnews,

d.DateCreated,

d.Username,

d.Password



};





GridView1.DataSource = dist;

}

protected void BrowseDistGrid_SelectedIndexChanged(object sender, EventArgs e)

{



}

protected void rdoBtnListExportOptions_SelectedIndexChanged(object sender, EventArgs e)

{



}



protected void LinkButton1_Click1(object sender, EventArgs e)

{

GridViewRow gvr = (GridViewRow)((LinkButton)sender).Parent.Parent; //get that selected row

//string AccountType = gvr.Cells[16].Text;

string CompanyName = gvr.Cells[2].Text;

string Address1 = gvr.Cells[3].Text;





Response.Redirect("Distributor.aspx?CompanyName=" + CompanyName

+ "&Address1=" + Address1



); //redirect to next page with selected values



}





protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.Header | e.Row.RowType == DataControlRowType.DataRow)

{

e.Row.Controls[1].Visible = false;



}

}

}
AnswerRe: export to excel from asp.net Pin
Samer Aburabie20-Nov-08 15:25
Samer Aburabie20-Nov-08 15:25 
GeneralRe: export to excel from asp.net Pin
Member 141625420-Nov-08 17:58
Member 141625420-Nov-08 17:58 
Questionhow to display confirmation data in formview prior to insert Pin
stanley.mark@usa.net19-Nov-08 11:53
stanley.mark@usa.net19-Nov-08 11:53 
QuestionWatermarking images in DB with a specific text Pin
reogeo200819-Nov-08 8:07
reogeo200819-Nov-08 8:07 
AnswerRe: Watermarking images in DB with a specific text Pin
Christian Graus19-Nov-08 8:17
protectorChristian Graus19-Nov-08 8:17 
Questioni got following error while using com lib to read word document uploaded by client through asp.net Pin
vikashjain02@gmail.com19-Nov-08 6:22
vikashjain02@gmail.com19-Nov-08 6:22 
AnswerRe: i got following error while using com lib to read word document uploaded by client through asp.net Pin
Christian Graus19-Nov-08 8:20
protectorChristian Graus19-Nov-08 8:20 
QuestionWhile i try to upload doc file in a folder throug ASP .net i got following error please help in solving it Pin
vikashjain02@gmail.com19-Nov-08 6:12
vikashjain02@gmail.com19-Nov-08 6:12 
AnswerRe: While i try to upload doc file in a folder throug ASP .net i got following error please help in solving it Pin
Christian Graus19-Nov-08 8:21
protectorChristian Graus19-Nov-08 8:21 
Questioncustom control set foucs problem Pin
lav naphade19-Nov-08 3:23
lav naphade19-Nov-08 3:23 
AnswerRe: custom control set foucs problem Pin
Christian Graus19-Nov-08 8:35
protectorChristian Graus19-Nov-08 8:35 
GeneralRe: custom control set foucs problem Pin
lav naphade19-Nov-08 18:18
lav naphade19-Nov-08 18:18 
QuestionList Box problem Pin
enthusiastic47719-Nov-08 2:18
enthusiastic47719-Nov-08 2:18 
AnswerRe: List Box problem Pin
Nishant Singh19-Nov-08 2:53
Nishant Singh19-Nov-08 2:53 
AnswerRe: List Box problem Pin
Christian Graus19-Nov-08 8:35
protectorChristian Graus19-Nov-08 8:35 
QuestionHELP!! DropDownList not displaying first record Pin
Member 340288619-Nov-08 1:59
Member 340288619-Nov-08 1:59 
AnswerRe: HELP!! DropDownList not displaying first record Pin
ToddHileHoffer19-Nov-08 2:08
ToddHileHoffer19-Nov-08 2:08 

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.