Monday, August 16, 2010

VB.NET DataGrid Question?

I have a DataGrid in VB.net and i use a select statement to populate the grid. One of the fields in the grid is an email address. How do I get it so that when the gird is filled a user can click on the email address and it will automatically know its a eamil address and open up outlook. I have seen it before I just dont knwo how to format that colume so that you can click on it and it knows its a email address.VB.NET DataGrid Question?
You need to ditch the datagrid, and use a datagridview.





The datagrid has been marked for retirement by microsoft, if your not to deep into your application then your going to do yourself a favor and upgrade your code now.





The datagrid view has a column type for clickable links


http://msdn2.microsoft.com/en-us/library鈥?/a>





The above link shows all column types, you want to use the link column type:





http://msdn2.microsoft.com/en-us/library鈥?/a>VB.NET DataGrid Question?
You want to change the HTML for the DataGrid. Open the web form with the DataGrid on it. Go to the HTML view, in Visual Studio click on the HTML link at the bottom of the window when in design view.





Scroll down until you find the tags for your DataGrid. Find the column for your email addresses. You want this column to be an asp:hyperlink column, so it needs to look like the following:





%26lt;asp:HyperLink NavigateUrl=


';%26lt;%# Container.DataItem


(';EmailAddress';)%%26gt;';/%26gt;





**Should all be on one line**





****NOTE: I used the Field Name 'EmailAddress' for demo purposes only*****





Hope this helps - Please check all the help features on the Microsoft site, there is a lot there including tutorials and contact with other developers.





Jen

No comments:

Post a Comment