Strong Coders Community

Where the extreme coders hang out.
Welcome to Strong Coders Community Sign in | Join | Help Messenger
in Search

Retrieving variable for file name

Last post 10-23-2006, 2:08 PM by Jeff224 . 5 replies.
Sort Posts: Previous Next
  •  10-20-2006, 8:55 PM 946
    • Jeff224 is not online. Last active: 11-11-2006, 8:50 PM Jeff224
    • Top 10 Contributor
      Male
    • Joined on 10-21-2006
    • Accokeek, Md
    • Posts 13
    • Points 195

    Retrieving variable for file name

    All,

    I have a form with a drop down list (populates from a DB)

    DataValudField = 126

    DataTextField = blah blah

     

    Once I select the blah blah from the ddl it displays a gridview.

     

    Then I have an export button that directs it to: cmpDataGridToExcel.vb

     

    All works great.

     

    What I would like to have it do when it ask if I want to save or open I would like it to automatically name the file the datatextfield (blahblah.xls)

     

    response.ContentType = "application/vnd.ms-excel"

            response.AddHeader( "Content-Disposition" , ( "attachment;filename=guide_name_display1.xls" ))

     

    How would I pass the datatextfield to the above code in the cmpDataGridToExcel?

     

    I have searched I have   tinkered but to no avail

    now you can understand my image Smile

     

    Jeff

    • Post Points: 20
    • Alert the moderators
  •  10-21-2006, 11:47 AM 950 in reply to 946
    • Kevin Jones is not online. Last active: 2006/11/12, 12:23 AM Kevin Jones
    • Top 10 Contributor
      Male
    • Joined on 07-27-2006
    • Charleston, SC
    • Posts 63
    • Points 895
    • Moderator

    Re: Retrieving variable for file name

    Couldn't you use DropDownList.SelectedValue?


    Cheers,
         Kevin
    • Post Points: 5
    • Alert the moderators
  •  10-21-2006, 8:35 PM 959 in reply to 950
    • Jeff224 is not online. Last active: 11-11-2006, 8:50 PM Jeff224
    • Top 10 Contributor
      Male
    • Joined on 10-21-2006
    • Accokeek, Md
    • Posts 13
    • Points 195

    Re: Retrieving variable for file name

    I did try that, but must have done it wrong. the value is a #, I want to use the text value.

    when it tried to use the value it gave me an error that it couldn't convert or use int as string.

    tried many different ways but just can't seem to get it.

    • Post Points: 20
    • Alert the moderators
  •  10-21-2006, 9:42 PM 960 in reply to 959
    • Kevin Jones is not online. Last active: 2006/11/12, 12:23 AM Kevin Jones
    • Top 10 Contributor
      Male
    • Joined on 07-27-2006
    • Charleston, SC
    • Posts 63
    • Points 895
    • Moderator

    Re: Retrieving variable for file name

    If you want the text and not the value then use DropDownList.SelectedItem.Text
    Cheers,
         Kevin
    • Post Points: 20
    • Alert the moderators
  •  10-23-2006, 12:45 PM 963 in reply to 960
    • Jeff224 is not online. Last active: 11-11-2006, 8:50 PM Jeff224
    • Top 10 Contributor
      Male
    • Joined on 10-21-2006
    • Accokeek, Md
    • Posts 13
    • Points 195

    Re: Retrieving variable for file name

    yes that would work, How do I pass the DropDownList1.SelectedItem.Text to

    cmpDataGridToExcel.DataGridToExcel(GridView1, Response)?

    that is the question.

    Thanks

    Jeff

    • Post Points: 5
    • Alert the moderators
  •  10-23-2006, 2:08 PM 964 in reply to 963
    • Jeff224 is not online. Last active: 11-11-2006, 8:50 PM Jeff224
    • Top 10 Contributor
      Male
    • Joined on 10-21-2006
    • Accokeek, Md
    • Posts 13
    • Points 195

    Re: Retrieving variable for file name

     

    This case is solved,

    One of the coders came to my office to do some testing on a Mac I have and I guess was tired of seeing me beating my head against the wall and showed me how it was done.

     

    By adding:

     Public Shared Sub DataGridToExcel(ByVal dgExport As GridView, ByVal response As HttpResponse, ByVal filename As String )

    And response.AddHeader("Content-Disposition", ("attachment;filename=" & filename & ".xls")) to the Public Class cmpDataGridToExcel

    And then adding  cmpDataGridToExcel.DataGridToExcel(GridView1, Response , DropDownList1.SelectedItem.Text ) to my button it is now working.

    I guess I'll learn this stuff one day.

     

    Thanks Kevin.

     

    Jeff

    • Post Points: 0
    • Alert the moderators

Powered by Community Server, by Telligent Systems