Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 27th, 2006, 12:07 AM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default DataGrid problem

Hello all
Is there any one can help me to have 4 datagrids that gets records from same table but with different sql statements?
I have 4 datagrids in a webform right now with the conditions that i wrote above.but it seems that datagrids fill with the first dataset and i have same datagrid at least. would you please tell me why i get the same datagrids?
thank you

  #2 (permalink)  
Old June 28th, 2006, 01:16 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

what is your code? it seems as if you are binding each grid to the same datasource.

  #3 (permalink)  
Old July 1st, 2006, 01:22 AM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default

i've written 2 sample of my datagrids as below:
1)
da = New SqlDataAdapter("select * from tbHGInf where Row is not null and Row<>' ' and DateDiff(d,ModifyDate,GetDate())<=7 order by HGNo Asc", con)
        ds = New DataSet
        da.Fill(ds, "tbHGInf")
        DataGrid1.DataSource = ds.Tables("tbHGInf").DefaultView
        DataGrid1.DataBind()

2)
da5 = New SqlDataAdapter("select * from tbHGInf where CustomRow is not null and CustomRow<>' ' and DateDiff(d,ModifyDate,GetDate())<=7 ", con)
        ds5 = New DataSet
        da5.Fill(ds5, "tbHGInf1")
        DataGrid6.DataSource = ds5.Tables("tbHGInf1").DefaultView
        DataGrid6.DataBind()
 *tbHgInf is my table name and Row and CustomRow are two different fileds of my table
i would be very thankfull if you help me
thank you again


  #4 (permalink)  
Old July 1st, 2006, 10:51 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

it seems like it should work. Is this code in your Page_Load? Do you have it in an If NOT IsPostBack statement?

  #5 (permalink)  
Old July 1st, 2006, 11:46 PM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default

thank you for your reply
this code is in my page_Load and i didn't use if not ispostback.should i use it?i will try it.but where should i put this if clause??for binding the datagrid???
thank you for your help again.
  #6 (permalink)  
Old July 2nd, 2006, 08:57 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

If NOT IsPostBack Then
   ..your code above goes here...
End If

  #7 (permalink)  
Old July 3rd, 2006, 12:31 AM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default

I did it as you wrote but it is like before:(where is the problem?:(

  #8 (permalink)  
Old July 4th, 2006, 12:55 AM
Registered User
 
Join Date: Jul 2006
Location: chandigarh, chandigarh, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think that u shold use
if(!IsPostBack)
{

// Your code comes in this section..
}

  #9 (permalink)  
Old July 4th, 2006, 10:54 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

It depends on wether the person is using VB or C#. It looks like the code posted above is in VB.

  #10 (permalink)  
Old July 4th, 2006, 11:05 PM
Friend of Wrox
 
Join Date: May 2005
Location: tehran, tehran, Iran.
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default

yes the code is in vb.but i think we put if not ispostback for avoiding the same datagrids.but it does'nt shows the same datagrids.my datagrid for the same tables but with different strsqls are looking different.and i have different looking datagrids when the page loads but these different looking datagrids have same records in it and it ignored the strsqls it used the first strsql.
ofcourse i used if not ispostback as you said but it is as same as before.
where is the problem?:(




Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with datagrid Shishir ASP.NET 1.0 and 1.1 Professional 1 January 6th, 2007 09:01 AM
Datagrid Problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 December 5th, 2006 03:09 AM
DataGrid Problem anujrathi VB.NET 2002/2003 Basics 2 June 15th, 2006 02:18 AM
DataGrid Problem anujrathi ASP.NET 2.0 Basics 1 June 12th, 2006 03:52 PM
Datagrid problem dotnetprogrammer VS.NET 2002/2003 1 February 17th, 2005 05:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.