HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 1.1ASP.Net 1.1Need help paging a datagridNeed help paging a datagrid
Previous
 
Next
New Post
3/16/2007 4:15 PM
 
I bring information from a DataBase but I can't find the way to paging and asp datagrid
This is my VB code behind:
Imports DotNetNuke
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.IO
Imports System.Collections
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Text.RegularExpressions
Imports System.Reflection
Imports System.Text
Imports System.Text.StringBuilder
Imports DotNetNuke.Security.PortalSecurity
Imports DotNetNuke.Security.Roles
Imports Microsoft.VisualBasic
Imports Microsoft.ApplicationBlocks.Data

Namespace MyModule


Public MustInherit Class MyModule
Inherits Entities.Modules.PortalModuleBase


Dim ConnectionString As String = "Server=(local);Database=MyDB;uid=sa;pwd=MyPass;"
Dim mySqlString As StringBuilder = New StringBuilder
Protected WithEvents DataGrid2 As System.Web.UI.WebControls.DataGrid
Protected WithEvents ItemNameLabel As System.Web.UI.WebControls.Label
Protected WithEvents DataGrid As System.Web.UI.WebControls.DataGrid
Protected WithEvents SearchByName As System.Web.UI.WebControls.TextBox
Protected WithEvents btnExecuteSQL As System.Web.UI.WebControls.Button
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents lblcatego As System.Web.UI.WebControls.Label
Dim myParam As SqlParameter = New SqlParameter("@SearchByName", SqlDbType.VarChar, 150)


Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
Dim catal As String
Dim catname As String
'this parameter came from another module
catal = Request.QueryString("catalogo") 'this parameter came from another module
catname = Request.QueryString("catname") 'this parameter came from another module
lblcatego.Text = catname
MyConnection = New SqlConnection("Server=(local);Database=MyDB;uid=sa;pwd=MyPass;")
MyCommand = New SqlDataAdapter("select I.PARTNUMBER,I.[NAME],O.ITEMDESCRIPTION,O.ITEMIMAGEPATH,PATH from ITEMINFO O INNER JOIN ITEM I ON( I.ITEMINFOID = O.ITEMINFOID) INNER JOIN ITEMGROUPDETAIL D ON( I.ITEMID = D.ITEMID) INNER JOIN ITEMGROUP G ON( G.ITEMGROUPID = D.ITEMGROUPID) where G.ITEMGROUPID='" + catal + "' ORDER BY I.PARTNUMBER", MyConnection)

DS = New DataSet


MyCommand.Fill(DS, "PRODUCTS")

DataGrid.DataSource = DS
DataGrid.DataMember = "PRODUCTS"
DataGrid.DataBind()


End Sub
Protected Sub DynamicSQL(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecuteSQL.Click

myParam.Value = SearchByName.Text()
mySqlString.Append("select I.PARTNUMBER,I.[NAME],O.ITEMDESCRIPTION,O.ITEMIMAGEPATH,PATH from ITEMINFO O ")
mySqlString.Append("INNER JOIN ITEM I ")
mySqlString.Append("ON( I.ITEMINFOID = O.ITEMINFOID) ")
mySqlString.Append("WHERE [NAME] like '%' + @SearchByName + '%' ORDER BY I.PARTNUMBER")
ShowData(SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, mySqlString.ToString, myParam))


End Sub
Private Sub ShowData(ByVal MyIDataReader As IDataReader)

DataGrid1.DataSource = MyIDataReader
DataGrid1.DataBind()
DataGrid.Visible = False


End Sub



Private Sub InitializeComponent()

End Sub


End Class
End Namespace

And this is my ASP code:
<%@ Control language="vb" AutoEventWireup="false"
            Inherits="MyModule.MyModule"
            CodeBehind="MyModule.ascx.vb"%>
<P><asp:textbox id="SearchByName" runat="server"></asp:textbox><asp:button id="btnExecuteSQL" runat="server" Text="Search By Product"></asp:button>&nbsp;</P>
<p align="right"><asp:Label ID="lblcatego" Runat="server"></asp:Label></p>
<P><asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="false" EnableViewState="false"
        HeaderStyle-BackColor="#aaaadd" Font-Size="8pt" Font-Name="Verdana" CellSpacing="0" CellPadding="3"
        ShowFooter="false" BorderColor="black" BackColor="#ccccff" Width="700">
        <Columns>
            <asp:TemplateColumn HeaderText="PRODUCT NAME" SortExpression="NAME">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "[NAME]")  %>
                    <BR>
                    <BR>
                    <%#DataBinder.Eval(Container.DataItem, "[PARTNUMBER]") %>
                </ItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="DESCRIPTION" SortExpression="ITEMDESCRIPTION">
                <ItemTemplate>
                    <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ITEMDESCRIPTION") %>' ID="Label1"/>
                </ItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="ITEMIMAGEPATH" SortExpression="ITEMIMAGEPATH">
                <ItemTemplate>
                    <asp:Image id="Image1" Width="104px" Height="95px" runat="server" ImageURL='<%# DataBinder.Eval(Container.DataItem, "PATH") + DataBinder.Eval(Container.DataItem, "ITEMIMAGEPATH")%>'>
                    </asp:Image>
                </ItemTemplate>
            </asp:TemplateColumn>
        </Columns>
    </asp:datagrid></P>
<asp:datagrid id="DataGrid" runat="server" AutoGenerateColumns="false" EnableViewState="false"
    HeaderStyle-BackColor="#aaaadd" Font-Size="8pt" Font-Name="Verdana" CellSpacing="0" CellPadding="3"
    ShowFooter="false" BorderColor="black" BackColor="#ccccff" Width="700">
    <Columns>
        <asp:TemplateColumn HeaderText="PRODUCT NAME" SortExpression="NAME">
            <ItemTemplate>
                <%# DataBinder.Eval(Container.DataItem, "[NAME]")  %>
                <BR>
                <BR>
                <%#DataBinder.Eval(Container.DataItem, "[PARTNUMBER]") %>
            </ItemTemplate>
        </asp:TemplateColumn>
        <asp:TemplateColumn HeaderText="DESCRIPTION" SortExpression="ITEMDESCRIPTION">
            <ItemTemplate>
                <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ITEMDESCRIPTION") %>' ID="Label2"/>
            </ItemTemplate>
        </asp:TemplateColumn>
        <asp:TemplateColumn HeaderText="ITEMIMAGEPATH" SortExpression="ITEMIMAGEPATH">
            <ItemTemplate>
                <img width="104" Height="95" runat=server src='<%# DataBinder.Eval(Container.DataItem, "PATH") + DataBinder.Eval(Container.DataItem, "ITEMIMAGEPATH")%>'>
            </ItemTemplate>
        </asp:TemplateColumn>
    </Columns>
</asp:datagrid>
<P></P>
If anybody could give a tip I'll be grateful.
 Need more information, just ask ;-)
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 1.1ASP.Net 1.1Need help paging a datagridNeed help paging a datagrid


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

Attend A Webinar
Start  Professional Edition Trial
Have Someone Contact Me

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Sponsors

DotNetNuke Corporation

DotNetNuke (DNN) provides a suite of solutions that make designing, building and managing feature-rich sites and communities fast, easy and cost-effective. The DotNetNuke Platform CMS is the foundation for more than one million websites worldwide. DNN Social, our newest solution, enables businesses to create immersive, interactive communities. Thousands of organizations like True Value Hardware, Bose, Cornell University, Glacier Water, Dannon, Delphi, USAA, NASCAR, Northern Health and the City of Denver have leveraged DNN to deploy highly engaging business- critical websites. Our rapid growth in product sales and deployments resulted in DotNetNuke Corp. being named one of the fastest growing private companies in America by Inc. Magazine in 2011 and 2012.