AutoPostBAck problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

HELP!!!!

I have a ListBox control, when one of the item is clicked I am using a
series of porperties and methos for Reponse class in order to allow download
diff files. The problem is that it doesn't matter what is clicked after a
item within the listBox is cliecked always the SelectedIndexChanged method
for the listBox is executed. Here is the code:

private void pdfListBox_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
pdfListBox.Enabled = false;
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.Clear();
Response.AppendHeader("Content-Disposition",
"attachment;Filename=Report.pdf");
Response.TransmitFile(pdfListBox.SelectedValue);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}

Any help wil lbe greatlly appreciated.
 
In
talvaro said:
HELP!!!!

I have a ListBox control, when one of the item is clicked I am using a
series of porperties and methos for Reponse class in order to allow
download diff files. The problem is that it doesn't matter what is
clicked after a item within the listBox is cliecked always the
SelectedIndexChanged method for the listBox is executed. Here is the
code:

private void pdfListBox_SelectedIndexChanged(object sender, EventArgs
e) {
try
{
pdfListBox.Enabled = false;
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.Clear();
Response.AppendHeader("Content-Disposition",
"attachment;Filename=Report.pdf");
Response.TransmitFile(pdfListBox.SelectedValue);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}

Any help wil lbe greatlly appreciated.

I am not sure what your question is. The SelectedIndexChanged method will
always be executed.
If you are not getting proper file names out, it might be because each
ListItem contains both value and text. Depending on how you are loading the
listbox, value may be the 'index' not the displayed file name.Try this:

string filename = pdfListBox.SelectedItem.Text;
Response.TransmitFile(filename);

BTW the reason I broke it into two statements is that way you can use the
debugger to watch the string filename.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top