Select to view content in your preferred language

Hyperlinkbutton in datagrid from a query or identify

639
1
06-17-2010 08:48 AM
AngelGonzalez
Frequent Contributor
How would you go about adding a Hyperlinkbutton to a field in a datagrid returned from a query, identify or maptips? Note: the Hyperlink is a url with the value/attribute of the field pass in as a parameter for the url. Any samples are appreciated.

Thanks
0 Kudos
1 Reply
TylerMunn
Emerging Contributor
Here is what I did - upon loading the row, it goes thru each field to see if one of the fields contains URL. It then takes that URL and does a string manipulation so that only the value for the URL field is present, and opens it in a new url when you click the "More Info" button. Currently I just have it displayed in a messagebox to show that it works.

 private void QueryDetailsDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            string value = e.Row.DataContext.ToString();

            try
            {

                string s = e.Row.DataContext.ToString();

                if (s.Contains("URL"))
                {
                    string[] sSplit = s.Split(',');
                    string[] link = sSplit[1].Split(']');

                    //assigns the link value to a global variable
                    URLlink = link[0];

                    //blnMoreInfo controls whether or not the more info button brings up a page
                    blnMoreInfo = true;

                  //HtmlPage.PopupWindow(new Uri("http://www.silverlight.net"), "new", options);


                }
                else
                {
                }
            }
            catch
            {
            }


        }


private void btn_MoreInfo(object sender, RoutedEventArgs e)
        {

            if (blnMoreInfo == true)
            {
                MessageBox.Show(URLlink);
            }
            else
            {
                MessageBox.Show("No Info Available");
            }

        }


I found the example on the old forums if you want to look into it more.
edit - I just realized that upon selecting multiple features it does not always change the BlnMoreInfo properly, but the rest of the code works fine.
0 Kudos