473,856 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with Windows DataGrid and DataBinding (Urgent)

Hello all,
I'm trying to display a dataset into a datagrid and format the datagrid
columns but I'm having a hard time with it. I've tried the MSDN examples but
they don't seem to work.

Basically, what I want to do is that, on a button click, the dataset fills
up dynamically, binds to the datagrid, and displays the data. This is my
code:

mySql = "select itemID, OrderDate " +
"from ClientTrans where " +
"clientID = " + txtClientID.Tex t;
DBConnection DBConn = new DBConnection("S QLServer", mySql);
DataSet DSMyTrans = DBConn.Connecti on();

//I use either one of the following two for the databinding
//DGOrders.DataSo urce = MyTransDS.Table s["MyTable"].DefaultView;
//DGOrders.SetDat aBinding(DSMyTr ans, "");

I only need some way to format the columns in the datagrid (column width,
headertext, etc...) and I've searched through MSDN but to no avail. I've
tried TableStyles:
DataGridTableSt yle myTS = new DataGridTableSt yle();
ts1.MappingName = "Clients";
DataGridBoolCol umn myDataCol = new DataGridBoolCol umn();
myDataCol.Heade rText = "From Date";
myDataCol.Mappi ngName = "Current";

ts1.GridColumnS tyles.Add(myDat aCol);
DGOrders.TableS tyles.Add(ts1);

but nothing happens.
Are there any links that show how to format datagrids (from the dataset
fill)?

John
Nov 13 '05 #1
4 7038
John,

Well, if you cut and pasted your code then I guess you're not using the
right variable. First you're using ' myTS ' and then you're referring to '
ts1 ' in the next line of code.

DataGridTableSt yle myTS = new DataGridTableSt yle();
ts1.MappingName = "Clients";

Could that be the problem?

Regards, Jim

"John" <None> schreef in bericht
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hello all,
I'm trying to display a dataset into a datagrid and format the datagrid
columns but I'm having a hard time with it. I've tried the MSDN examples but they don't seem to work.

Basically, what I want to do is that, on a button click, the dataset fills
up dynamically, binds to the datagrid, and displays the data. This is my
code:

mySql = "select itemID, OrderDate " +
"from ClientTrans where " +
"clientID = " + txtClientID.Tex t;
DBConnection DBConn = new DBConnection("S QLServer", mySql);
DataSet DSMyTrans = DBConn.Connecti on();

//I use either one of the following two for the databinding
//DGOrders.DataSo urce = MyTransDS.Table s["MyTable"].DefaultView;
//DGOrders.SetDat aBinding(DSMyTr ans, "");

I only need some way to format the columns in the datagrid (column width,
headertext, etc...) and I've searched through MSDN but to no avail. I've
tried TableStyles:
DataGridTableSt yle myTS = new DataGridTableSt yle();
ts1.MappingName = "Clients";
DataGridBoolCol umn myDataCol = new DataGridBoolCol umn();
myDataCol.Heade rText = "From Date";
myDataCol.Mappi ngName = "Current";

ts1.GridColumnS tyles.Add(myDat aCol);
DGOrders.TableS tyles.Add(ts1);

but nothing happens.
Are there any links that show how to format datagrids (from the dataset
fill)?

John

Nov 13 '05 #2
What sort of application is that? Windows Form? Web Form? What is in your
DBConnection class?

"John" <None> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hello all,
I'm trying to display a dataset into a datagrid and format the datagrid
columns but I'm having a hard time with it. I've tried the MSDN examples but they don't seem to work.

Basically, what I want to do is that, on a button click, the dataset fills
up dynamically, binds to the datagrid, and displays the data. This is my
code:

mySql = "select itemID, OrderDate " +
"from ClientTrans where " +
"clientID = " + txtClientID.Tex t;
DBConnection DBConn = new DBConnection("S QLServer", mySql);
DataSet DSMyTrans = DBConn.Connecti on();

//I use either one of the following two for the databinding
//DGOrders.DataSo urce = MyTransDS.Table s["MyTable"].DefaultView;
//DGOrders.SetDat aBinding(DSMyTr ans, "");

I only need some way to format the columns in the datagrid (column width,
headertext, etc...) and I've searched through MSDN but to no avail. I've
tried TableStyles:
DataGridTableSt yle myTS = new DataGridTableSt yle();
ts1.MappingName = "Clients";
DataGridBoolCol umn myDataCol = new DataGridBoolCol umn();
myDataCol.Heade rText = "From Date";
myDataCol.Mappi ngName = "Current";

ts1.GridColumnS tyles.Add(myDat aCol);
DGOrders.TableS tyles.Add(ts1);

but nothing happens.
Are there any links that show how to format datagrids (from the dataset
fill)?

John

Nov 13 '05 #3
Sorry. Since I was in hurry, I made that mistake.
Here's the code for the datagrid in the Windows form:

string mySql;
mySql = "select itemID " +
"from ClientTrans where " +
"clientID = " + txtClientID.Tex t;
DataSet DSMyTrans = new DataSet();
SqlConnection SQLConn = new SqlConnection(" Data Source=localhos t; Integrated
Security=SSPI;" +
"Initial Catalog=invoici ng");
SqlDataAdapter MyDataAdapterCl ients = new SqlDataAdapter (mySql, SQLConn);
MyDataAdapterCl ients.TableMapp ings.Add("Table ","MyTable" );
MyDataAdapterCl ients.Fill(DSMy Trans);
DGOrders.DataSo urce = DSMyTrans.Table s["MyTable"].DefaultView;
DataGridTableSt yle ts1 = new DataGridTableSt yle();
ts1.MappingName = "Clients";
DataGridBoolCol umn myDataCol = new DataGridBoolCol umn();
myDataCol.Heade rText = "From Date";
myDataCol.Mappi ngName = "Current";
ts1.GridColumnS tyles.Add(myDat aCol);
DGOrders.TableS tyles.Add(ts1);

I can see the data in the datagrid but I would like to change the different
column properties (the headertext, column width, etc...) dyamically? I've
tried tons of way to change the column header text but nothing happens.
Thanks,
John
Nov 13 '05 #4
It's a Windows form.
Here's the code with the connection..

string mySql;
mySql = "select itemID " +
"from ClientTrans where " +
"clientID = " + txtClientID.Tex t;
DataSet DSMyTrans = new DataSet();
SqlConnection SQLConn = new SqlConnection(" Data Source=localhos t; Integrated
Security=SSPI;" +
"Initial Catalog=invoici ng");
SqlDataAdapter MyDataAdapterCl ients = new SqlDataAdapter (mySql, SQLConn);
MyDataAdapterCl ients.TableMapp ings.Add("Table ","MyTable" );
MyDataAdapterCl ients.Fill(DSMy Trans);
DGOrders.DataSo urce = DSMyTrans.Table s["MyTable"].DefaultView;
DataGridTableSt yle ts1 = new DataGridTableSt yle();
ts1.MappingName = "Clients";
DataGridBoolCol umn myDataCol = new DataGridBoolCol umn();
myDataCol.Heade rText = "From Date";
myDataCol.Mappi ngName = "Current";
ts1.GridColumnS tyles.Add(myDat aCol);
DGOrders.TableS tyles.Add(ts1);

Thanks,
John

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:uX******** ******@TK2MSFTN GP10.phx.gbl...
What sort of application is that? Windows Form? Web Form? What is in your
DBConnection class?

"John" <None> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hello all,
I'm trying to display a dataset into a datagrid and format the datagrid
columns but I'm having a hard time with it. I've tried the MSDN examples

but
they don't seem to work.

Basically, what I want to do is that, on a button click, the dataset fills up dynamically, binds to the datagrid, and displays the data. This is my
code:

mySql = "select itemID, OrderDate " +
"from ClientTrans where " +
"clientID = " + txtClientID.Tex t;
DBConnection DBConn = new DBConnection("S QLServer", mySql);
DataSet DSMyTrans = DBConn.Connecti on();

//I use either one of the following two for the databinding
//DGOrders.DataSo urce = MyTransDS.Table s["MyTable"].DefaultView;
//DGOrders.SetDat aBinding(DSMyTr ans, "");

I only need some way to format the columns in the datagrid (column width, headertext, etc...) and I've searched through MSDN but to no avail. I've
tried TableStyles:
DataGridTableSt yle myTS = new DataGridTableSt yle();
ts1.MappingName = "Clients";
DataGridBoolCol umn myDataCol = new DataGridBoolCol umn();
myDataCol.Heade rText = "From Date";
myDataCol.Mappi ngName = "Current";

ts1.GridColumnS tyles.Add(myDat aCol);
DGOrders.TableS tyles.Add(ts1);

but nothing happens.
Are there any links that show how to format datagrids (from the dataset
fill)?

John


Nov 13 '05 #5

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

Similar topics

4
3654
by: CGuy | last post by:
Hi, I have an ASPX page which has a datagrid and this datagrid is bound to a Custom Collection. sample code this.DataGrid1.DataSource = UserManager.Users; this.DataGrid1.DataBind();
0
3650
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
6
1783
by: VB Programmer | last post by:
I have an itemtemplate in a datagrid. I'm trying to set it's value based on data. Having no trouble with the textbox. But, how do I do the same thing for a dropdownlist???? <ItemTemplate> <asp:DropDownList id="ddlYesNo" runat="server" > <asp:ListItem Value="-">-</asp:ListItem> <asp:ListItem Value="Yes">Yes</asp:ListItem> <asp:ListItem Value="No">No</asp:ListItem> </asp:DropDownList>
4
2143
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 Delete button on the end of each row. I am unable to gain access to the event when the button is clicked. I don't fully understand how the click gets connected to the C# code,
2
1926
by: momo | last post by:
Hello Guys, I have a bit of a problem, I created a Dll called SecureQueryStringDll.dll and I had the dll put bin folder of my application first and it did not work so I then put it in the bin folder of c:\inetpub\wwwroot and it still does not work. Here is the error I get from it: temporary asp.net files\root\d16a94c5\8b912d73\assembly\dl2\1dc1ef5c\006575a4_827ac301\metabuilders.webcontrols.rowselectorcolumn.dll"...
2
1014
by: Mark B | last post by:
I have a Datagrid working fine, outputting: Group Most Popular Product Code -------- ------------------------------- Earth.New Zealand 32 Earth.New Zealand
7
3039
by: Mark B | last post by:
Can someone write some VB.Net example code for me that does this: 1) Creates a gridview control with the results of a SQL stored procedure that has 1 parameter (text) 2) Adds an extra column that displays the result of a VB.Net function that uses a value from an existing column I have spent 4 hours trying to do this after Googling for examples... There are many new concepts that I haven't had much experience with...
0
9920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9764
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10699
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10790
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10390
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7932
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5762
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4176
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.