2

I am new to .net platform and I want to create a data grid view that takes the data from database table and create Hyperlink field in the grid which displays the text as the text in the column of the table and url basing on the id.

Like url can be http://localhost:9000/admin.aspx?id=10 and text displayed should "Admin".

I referred this link but http://www.java2s.com/Tutorial/ASP.NET/0380__Data-Binding/AddingaHyperlinkFieldcontroltotheGridView.htm this contains the code as per the Sql Server but I am using Mysql database .

Please tell me how I can achieve this.

2
  • Hi amandeep can you please show how did you fix that problem. I am facing this problem too search for other solutions but couldn't find anything helpful. Can you please tell me how to fix that. Thanks in advance :) Commented Oct 31, 2011 at 5:22
  • Hi usuf apart use the above answer then add this code to your web.config <system.data> <DbProviderFactories> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.1.6, Culture=neutral" /> </DbProviderFactories> </system.data> Commented Oct 31, 2011 at 5:36

1 Answer 1

2

Hi you can start with the code you have in the link provided, and customize it as needed.

When you want to connect to mySQL from .NET you should install the MySQL .NET Connector which provides you the MySQL.Data assembly and namespace.

after that you should just configure the connection string and SQL Command to speak the language MySQL can understand, the asp:SqlDataSource would most likely still work just needs to be told you are connecting to MySQL, for example look at this snippet:

<asp:SqlDataSource runat="server" ID="MySQLData"
    ConnectionString="server=127.0.0.1;User Id=xxxx;password=xxxx;database=myDataBase"
    ProviderName="MySql.Data.MySqlClient"
    SelectCommand="SELECT * FROM myTableName" />

in this way you can load the data as required. Make sure to have the mySQL .NET connector installed and referenced from your code...

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Davide for your reply,when I used the above code it is giving me the error:"unable to find the requested .net framework data provider. it may not be installed."Though I have added the MySql.Data.dll and MySql.Data.Entity.dll in my bin folder.I guess I need to make some changes in the web.config as well.Can you please tell me that what I am missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.