Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to get the count value for gridview from (sqlserver database)database [modified]

how to get the count value for gridview from (sqlserver database)database [modified]

Scheduled Pinned Locked Moved ASP.NET
databasehelphtmlsysadmindocker
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    priyamsc
    wrote on last edited by
    #1

    Hi, I am doing forum project. I have a doubt, tat how to count the value. that is, all the data which displays in gridview. in tat i need to show the reply value [count the value from database].it means in database i hv field lke pid,pstreplyid,uid,tit,sub ...., in tat wen i create new msg it ll save in database giving pid automaticaly and in pstreplyid if its newmsg it creates 0 if its reply ten it takes pid value. in gridview what i wud lke to display is, the reply value, if the pid(2) has 3 reply means, the field of reply shud show 3. but i hv given query which displays only the new msg tat is pstreplyid=0. i need to display new msg at the same time it should display the replyvalue also. but i dnt knw how to count tat value so pls help me to do. you just give me the suggestion to overcome the issue. this is the gridview coding ============================

    page load()
    {
    string k = "select *,(select uname from login where login.uid=thread.uid)as uname from thread where pstreplyid=0";
    adp = new SqlDataAdapter(k, con);
    DataSet ds = new DataSet();
    adp.Fill(ds);
    GridView1.DataSource = ds;
    GridView1.DataBind();
    }

    HTML ====

    <asp:TemplateField HeaderText="Thread">
    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("tit") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <
    <asp:LinkButton ID="LinkButton1" runat="server" Text='<% # Eval("tit") %>' CommandName ="viewmsg" CommandArgument ='<%# DataBinder.Eval(Container.DataItem,"pid")%>' >LinkButton</asp:LinkButton>
    <br />
    <%#Eval("sub") %>
    </ItemTemplate>
    <asp:BoundField HeaderText="Replies" DataField="pstreplyid"/>
    <asp:BoundField DataField="pdate" HeaderText="Post Date" />
    <asp:BoundField DataField="rdate" HeaderText="Reply Date" />
    <asp:TemplateField HeaderText="Posted By">

    Thank you in advance.

    k.priya

    modified on Sunday, August 9, 2009 12:08 PM

    A 1 Reply Last reply
    0
    • P priyamsc

      Hi, I am doing forum project. I have a doubt, tat how to count the value. that is, all the data which displays in gridview. in tat i need to show the reply value [count the value from database].it means in database i hv field lke pid,pstreplyid,uid,tit,sub ...., in tat wen i create new msg it ll save in database giving pid automaticaly and in pstreplyid if its newmsg it creates 0 if its reply ten it takes pid value. in gridview what i wud lke to display is, the reply value, if the pid(2) has 3 reply means, the field of reply shud show 3. but i hv given query which displays only the new msg tat is pstreplyid=0. i need to display new msg at the same time it should display the replyvalue also. but i dnt knw how to count tat value so pls help me to do. you just give me the suggestion to overcome the issue. this is the gridview coding ============================

      page load()
      {
      string k = "select *,(select uname from login where login.uid=thread.uid)as uname from thread where pstreplyid=0";
      adp = new SqlDataAdapter(k, con);
      DataSet ds = new DataSet();
      adp.Fill(ds);
      GridView1.DataSource = ds;
      GridView1.DataBind();
      }

      HTML ====

      <asp:TemplateField HeaderText="Thread">
      <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("tit") %>'></asp:TextBox>
      </EditItemTemplate>
      <ItemTemplate>
      <
      <asp:LinkButton ID="LinkButton1" runat="server" Text='<% # Eval("tit") %>' CommandName ="viewmsg" CommandArgument ='<%# DataBinder.Eval(Container.DataItem,"pid")%>' >LinkButton</asp:LinkButton>
      <br />
      <%#Eval("sub") %>
      </ItemTemplate>
      <asp:BoundField HeaderText="Replies" DataField="pstreplyid"/>
      <asp:BoundField DataField="pdate" HeaderText="Post Date" />
      <asp:BoundField DataField="rdate" HeaderText="Reply Date" />
      <asp:TemplateField HeaderText="Posted By">

      Thank you in advance.

      k.priya

      modified on Sunday, August 9, 2009 12:08 PM

      A Offline
      A Offline
      Arindam Sinha
      wrote on last edited by
      #2

      priyamsc wrote:

      how to count the value. that is, all the data which displays in gridview

      Try out ds.Tables[0].Rows.Count..(just check the syntax :))

      Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.

      P 1 Reply Last reply
      0
      • A Arindam Sinha

        priyamsc wrote:

        how to count the value. that is, all the data which displays in gridview

        Try out ds.Tables[0].Rows.Count..(just check the syntax :))

        Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.

        P Offline
        P Offline
        priyamsc
        wrote on last edited by
        #3

        could you say little bit clearly

        k.priya

        A 1 Reply Last reply
        0
        • P priyamsc

          could you say little bit clearly

          k.priya

          A Offline
          A Offline
          Arindam Sinha
          wrote on last edited by
          #4

          I think, you can get the count of rows which you are looking for. ds.Tables[0].Rows.Count would give you the count of rows. Let me know if you are looking for something else. :)

          Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups