473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Help with Datagrid class. Trying to remove it in the following case..

here's C sharp code:

Start code...

private void searchBtn_Click(object sender, System.EventArgs e)
{

//For sqlCommand1 is a search by Wkst ID (employeeID on pubs) params
if (txtEmployeeID.Text.Length > 0)
{
sqlCommand1.Parameters["@txtEmployeeID"].Value =
txtEmployeeID.Text;
sqlConnectSMS.Open();
System.Data.SqlClient.SqlDataReader dreader;
dreader = sqlCommand1.ExecuteReader();

DataGrid1.DataSource = dreader;
DataGrid1.DataBind();

dreader.Close();
sqlConnectSMS.Close();
}
else
{
//resets the data source to blank
DataGrid1.DataSource = null;
DataGrid1.DataBind();
}

....

}

End code

Basically, my question is in reference to the case when the if fails
(if (txtEmployeeID.Text.Length > 0)) and it goes to the else. This
means that I want DataGrid1 totally removed. The above shows up as
'nothing' on the asp.net page, but leaves this blank space. The reason
I see this page is because I have 4 DataGrid's back to back. If the
first 3 DataGrid objects are all set to null (like I have above), and
the DataGrid4 is present, then DataGrid4 has rows to display. On my
asp.net page, I have this huge space where the 3 datagrid's are blank.
That's because on my design view, it shows like this:

ASP.PAGE
Textbox(s)
DataGrid1
DataGrid2
DataGrid3
DataGrid4

I'm wondering if there is a command for the DataGrid to entirely remove
it, so that the space is removed.

Ideally, if the above situation happened, I'd want the DataGrid4 table
to show up right near the top of my page.

Thanks for any comments.
-Dan

Nov 19 '05 #1
1 1214
Hi,

you can try to set the Visible property of the datagrid to false, if the
datasource is null and you do not want to display the grid.
--
Saravanan K V
"Dan11" wrote:
here's C sharp code:

Start code...

private void searchBtn_Click(object sender, System.EventArgs e)
{

//For sqlCommand1 is a search by Wkst ID (employeeID on pubs) params
if (txtEmployeeID.Text.Length > 0)
{
sqlCommand1.Parameters["@txtEmployeeID"].Value =
txtEmployeeID.Text;
sqlConnectSMS.Open();
System.Data.SqlClient.SqlDataReader dreader;
dreader = sqlCommand1.ExecuteReader();

DataGrid1.DataSource = dreader;
DataGrid1.DataBind();

dreader.Close();
sqlConnectSMS.Close();
}
else
{
//resets the data source to blank
DataGrid1.DataSource = null;
DataGrid1.DataBind();
}

....

}

End code

Basically, my question is in reference to the case when the if fails
(if (txtEmployeeID.Text.Length > 0)) and it goes to the else. This
means that I want DataGrid1 totally removed. The above shows up as
'nothing' on the asp.net page, but leaves this blank space. The reason
I see this page is because I have 4 DataGrid's back to back. If the
first 3 DataGrid objects are all set to null (like I have above), and
the DataGrid4 is present, then DataGrid4 has rows to display. On my
asp.net page, I have this huge space where the 3 datagrid's are blank.
That's because on my design view, it shows like this:

ASP.PAGE
Textbox(s)
DataGrid1
DataGrid2
DataGrid3
DataGrid4

I'm wondering if there is a command for the DataGrid to entirely remove
it, so that the space is removed.

Ideally, if the above situation happened, I'd want the DataGrid4 table
to show up right near the top of my page.

Thanks for any comments.
-Dan

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
2
by: Dave Bailey | last post by:
I am trying to dynamically build a DataGrid dynamically. The code runs OK but the DataGrid is never built and displayed. Can someone look at the following code and see if they can determine what...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
by: | last post by:
The following code: Private Sub ClearControls(ByVal ctrl As Control) Dim i As Int32 For i = ctrl.Controls.Count - 1 To 0 Step -1 ClearControls(ctrl.Controls(i))
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
4
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a...
0
by: laurent | last post by:
Environment: VS NET 2003 Fr Framework: 1.1 OS: WinXP SP2 Fr Hello I have a problem to add with pop-up and to delete in a datagrid(ButtonColumn delete) on WebForms. code button HTML which...
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.