none
Programmatically change <a> tag href using sql stored procedure results RRS feed

  • Question

  • Hi Everyone,

    I have a dropdown list which on change sets the value of a parameter in a stored procedure which then returns two values an id and a string. I want to be able to add these two values and some text to the href of an anchor tag programmatically but since the anchor tag has no datasource I am confused. Does anyone have an answer as to how this can be done?


    t

    Tuesday, April 2, 2013 8:55 PM

Answers

  • Hi helpdevelop,

    From your description it seems you want list of links (anchors) based on drop down list selection. You can create your href inside of stored procedure and then use some data listing control (i.e grid, repeater etc) and bind that field.

    Between , it seems this question is more appropriate in asp.net forums.


    Thanks and Regards, Shailesh B. Davara

    • Marked as answer by helpdevelop Friday, April 5, 2013 10:48 PM
    Wednesday, April 3, 2013 1:23 PM
  • What I ended up doing was making one of the controls postback upon index selection and then run a stored preocedure call passing in the parameter selected by the control. Then in while statement of the sql datareader I selected the anchor tag I needed to change and set its href.

    rdr = command.ExecuteReader();
    
                            //set the anchor tag
                            while (rdr.Read())
                            {
                                generalLink.HRef = "link text";
    
    
    
                            }

    Thanks for the assistance.


    t

    • Marked as answer by helpdevelop Friday, April 5, 2013 10:48 PM
    Friday, April 5, 2013 10:47 PM

All replies

  • You should tell us more. What type of application, where is tag located, etc.

    Miha Markic [MVP C#] http://blog.rthand.com

    Wednesday, April 3, 2013 8:28 AM
  • Hi helpdevelop,

    From your description it seems you want list of links (anchors) based on drop down list selection. You can create your href inside of stored procedure and then use some data listing control (i.e grid, repeater etc) and bind that field.

    Between , it seems this question is more appropriate in asp.net forums.


    Thanks and Regards, Shailesh B. Davara

    • Marked as answer by helpdevelop Friday, April 5, 2013 10:48 PM
    Wednesday, April 3, 2013 1:23 PM
  • The program is a website using c# that previously had all of its data retrieved using 2 different sql data sources(now stored procedure calls) the problem is that the data I am retrieving is no longer inside of a giant repeater control so I can't just use eval tags on all of the <a> tags, labels or other controls to retrieve the data. In addition I can't do a while tag for everything regarding some event on the page because their are multiple controls which can change the parameter passed in to the procedure and can't call the stored procedure on page load because the parameter of the dropdown list is passed in every time. Can someone please suggest an easy way to pull back the data for controls on the page that used to be in a repeater but are now outside?

    t

    Wednesday, April 3, 2013 2:50 PM
  • What I ended up doing was making one of the controls postback upon index selection and then run a stored preocedure call passing in the parameter selected by the control. Then in while statement of the sql datareader I selected the anchor tag I needed to change and set its href.

    rdr = command.ExecuteReader();
    
                            //set the anchor tag
                            while (rdr.Read())
                            {
                                generalLink.HRef = "link text";
    
    
    
                            }

    Thanks for the assistance.


    t

    • Marked as answer by helpdevelop Friday, April 5, 2013 10:48 PM
    Friday, April 5, 2013 10:47 PM