Hi, I jaust want to convert the example in the link below, for filtering and paging with gridview, in order to use in my page.

The example uses SQL with noorthwind database.
I think Visual Studio does not suppport mySql fuly,

I already download MYSQL driver do I also need MySQl data prvoider ?

(actulay I can get wotk MySQL with ASP NET but te problem with these controllers)


http://www.eggheadcafe.com/tutorials/aspnet/c67c4daa-83c2-4baa-aea4-2c8855527acb/aspnet-gridview-filtering-with-dropdownlist.aspx

asp:SqlDataSource ID="SqlDataSource2" runat="server" 
       ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"

And the code as I changed

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=classicmodels;USER=root;PASSWORD=123456;OPTION=3;"

And the error I get;
Keyword not supported: 'driver'.


How can I use mysql inside <asp:SqlDataSource I searched for <asp:MySqlDataSource sth but could not find a solution,

How can I overcome this problem ? Any idea ?

Recommended Answers

All 3 Replies

connection string does not solve my problem.
I have an example with 2 dropdownlist which gets its content from a table in Access database. I had difficult time in converting it to MySQL. (I have MYSQL drivers, and can get it work with other example uses conn string. but I could not find a tag.ç I mean, there is not sth like,
<asp:MySqlDataSource. So, How will I use this example exactly with Mysql. Please
check the code below and help me.

I am posting my full code, please Help. I want to get it work with MySQL database.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title>Untitled Page</title>
    <link rel="stylesheet" type="text/css" href="gridview.css" media="all" />

    <script type="text/javascript">
        function Highlight_On(obj)
        {
            if(obj != null)
            {
                obj.originalClassName = obj.className;
                obj.className = obj.className + 'HL';
            }
        }

        function Highlight_Off(obj)
        {
            if(obj != null)
            {
                obj.className = obj.originalClassName;
            }        
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <h3>Gridview with Filtering</h3>
            <div class="GridviewDiv">
            <table style="width: 540px" border="0" cellpadding="0" cellspacing="1" class="GridviewTable">
                <tr >

                    <td onmouseover="this.style.background='red';this.style.cursor='pointer'"
        onmouseout="this.style.background='orange';" onclick="location='http://www.google.com'">
        ID </td>                    

                    <td style="width: 120px;" >
                        First Name
                    </td>
                    <td style="width: 120px;">
                        Last Name
                    </td>
                    <td style="width: 130px;">
                        Department
                    </td>

                    <td style="width: 130px;">

                        Location
                    </td>



                </tr>
                <tr >
                    <td style="width: 40px;" >

                    </td>

                    <td style="width: 120px;">
                        &nbsp;</td>
                     <td style="width: 130px;">
                         &nbsp;</td>

                    <td style="width: 130px;">
                        <asp:DropDownList ID="ddldepartment" runat="server" AppendDataBoundItems="true" 
                            AutoPostBack="true" OnSelectedIndexChanged="PopulateCitiesDropDown" DataSourceID="dsPopulateDepartment" 
                            DataValueField="department" Font-Size="11px" Height="16px" Width="120px">
                            <asp:ListItem Text="All" Value="%"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td style="width: 130px;">
                        <asp:DropDownList ID="ddlLocation" runat="server" AppendDataBoundItems="true" 
                            AutoPostBack="true" DataSourceID="dsPopulateLocation" DataValueField="location" 
                            Font-Size="11px" Width="120px">
                            <asp:ListItem Text="All" Value="%"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td colspan="5">
                        <asp:GridView 
                        ID="Gridview1" 
                        runat="server" 
                        AutoGenerateColumns="False" 
                        AllowPaging="True"
                        AllowSorting="true" 
                        DataSourceID="dsGridview" 
                        Width="540px" 
                        PageSize="10" 
                        CssClass="Gridview"
                        onrowdatabound="gdvPeople_RowDataBound">  
                            <Columns>

            <asp:hyperlinkfield headertext="Title"
            datatextfield="id"
            datanavigateurlformatstring="title_details.aspx?titleid={0}"
            datanavigateurlfields="id" />
                                <asp:BoundField DataField="id" HeaderText="Sırala" SortExpression="id" ItemStyle-Width="40px"
                                    ItemStyle-HorizontalAlign="Center"  />
                                <asp:BoundField DataField="FirstName" HeaderText="Sırala" SortExpression="FirstName"
                                    ItemStyle-Width="120px" />
                                <asp:BoundField DataField="LastName" HeaderText="Sırala" SortExpression="LastName"
                                    ItemStyle-Width="120px" />
                                <asp:BoundField DataField="Department" HeaderText="Sırala" SortExpression="Department"
                                    ItemStyle-Width="130px" />
                                <asp:BoundField DataField="Location" HeaderText="Sırala" SortExpression="Location"
                                    ItemStyle-Width="130px" />
                            </Columns>
                        </asp:GridView>
                    </td>
                </tr>
            </table>
            </div>

            <asp:AccessDataSource ID="dsGridview" runat="server" DataSourceMode="DataSet"
            DataFile="Database2.mdb" 

            SelectCommand="SELECT * FROM T_Employees"
FilterExpression="Department like '{0}%'  and Location like '{1}%' ">
                <FilterParameters>
                    <asp:ControlParameter Name="Department" ControlID="ddldepartment" PropertyName="SelectedValue" />
                    <asp:ControlParameter Name="Location" ControlID="ddllocation" PropertyName="SelectedValue" />

                </FilterParameters>
            </asp:AccessDataSource>


            <asp:AccessDataSource ID="dsPopulateDepartment" runat="server" DataFile="Database2.mdb"  
                SelectCommand="SELECT DISTINCT Department from T_Employees"></asp:AccessDataSource>
            <asp:AccessDataSource ID="dsPopulateLocation" runat="server" DataFile="Database2.mdb"  
                SelectCommand="SELECT DISTINCT Location FROM T_Employees"></asp:AccessDataSource>
            <asp:AccessDataSource ID="dsPopulateFirstName" runat="server" DataFile="Database2.mdb"  
                SelectCommand="SELECT DISTINCT FirstName FROM T_Employees"></asp:AccessDataSource>
             <asp:AccessDataSource ID="dsPopulateLastName" runat="server" DataFile="Database2.mdb"  
                SelectCommand="SELECT DISTINCT LastName FROM T_Employees"></asp:AccessDataSource>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.