 |
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
|
|
|

June 27th, 2006, 12:07 AM
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

June 28th, 2006, 01:16 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
what is your code? it seems as if you are binding each grid to the same datasource.
|

July 1st, 2006, 01:22 AM
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 1st, 2006, 10:51 AM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
it seems like it should work. Is this code in your Page_Load? Do you have it in an If NOT IsPostBack statement?
|

July 1st, 2006, 11:46 PM
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

July 2nd, 2006, 08:57 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
If NOT IsPostBack Then
..your code above goes here...
End If
|

July 3rd, 2006, 12:31 AM
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I did it as you wrote but it is like before:(where is the problem?:(
|

July 4th, 2006, 12:55 AM
|
Registered User
|
|
Join Date: Jul 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I think that u shold use
if(!IsPostBack)
{
// Your code comes in this section..
}
|

July 4th, 2006, 10:54 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
It depends on wether the person is using VB or C#. It looks like the code posted above is in VB.
|

July 4th, 2006, 11:05 PM
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 |
|
 |