473,387 Members | 2,436 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,387 software developers and data experts.

Using Datagrid

I am trying to use a datagrid to pull information from a database. I prefer
to use latebinding to this. Well, I finally got my information to populate
the datagrid, but the information came out in a table format. Is there a way
that I can make the datagrid use list box or some other kind of grid?
Perhaps I am using the wrong components. Someone please help.
Nov 15 '05 #1
3 1782
First, are you using a windows or web application?

For windows forms apps:
ListView might do what you want

For customizing the datagrid, see:
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp

For web apps:
Repeater control
DataList control
--
Mike Mayer, C# MVP
mi**@mag37.com
http://www.mag37.com/csharp/
"Jeremy Ames" <yo******@here.com> wrote in message
news:eo**************@TK2MSFTNGP10.phx.gbl...
I am trying to use a datagrid to pull information from a database. I prefer to use latebinding to this. Well, I finally got my information to populate
the datagrid, but the information came out in a table format. Is there a way that I can make the datagrid use list box or some other kind of grid?
Perhaps I am using the wrong components. Someone please help.

Nov 15 '05 #2
I am sorry. I am using this on a web form. I have tried using the datalist
component and it tries to put the data into a table form as well. I would
assume that the repeater control will do the same. Is there an easy way to
get this info into a list box in a tabular format?

"Michael Mayer [C# MVP]" <mi**@mag37.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
First, are you using a windows or web application?

For windows forms apps:
ListView might do what you want

For customizing the datagrid, see:
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp

For web apps:
Repeater control
DataList control
--
Mike Mayer, C# MVP
mi**@mag37.com
http://www.mag37.com/csharp/
"Jeremy Ames" <yo******@here.com> wrote in message
news:eo**************@TK2MSFTNGP10.phx.gbl...
I am trying to use a datagrid to pull information from a database. I prefer to use latebinding to this. Well, I finally got my information to populate
the datagrid, but the information came out in a table format. Is there a way that I can make the datagrid use list box or some other kind of grid?
Perhaps I am using the wrong components. Someone please help.


Nov 15 '05 #3
You can use a repeater to do this. Just put <select></select> around a
repeater, and repeat the <option> tags. A repeater does no extra
formatting- it just repeats what you have in the ItemTemplate, optionally
inserting what you have in the SeparatorTemplate (good place for a
<br><hr>,etc)

Like so, if you have the pubs database:

Put this in your aspx:
<select>
<asp:Repeater ID="ListData" Runat=server>
<ItemTemplate>
<option value='<%#DataBinder.Eval(Container.DataItem, "au_id")%>'>
<%# DataBinder.Eval(Container.DataItem, "au_lname") %>
</option>
</ItemTemplate>
</asp:Repeater>
</select>
Then bind in your code-behind, (something like this)

protected System.Web.UI.WebControls.Repeater ListData;

private void Page_Load(object sender, System.EventArgs e)
{
BindList();

}

private void BindList()
{
DataTable dt = new DataTable();
using(SqlConnection conn = new SqlConnection( "User
ID=sa;Password=;Initial Catalog=pubs;Data Source=."))
{
SqlCommand cmd = new SqlCommand("select * from authors", conn);
SqlDataAdapter da = new SqlDataAdapter( cmd);

conn.Open();
da.Fill( dt);

}
ListData.DataSource = dt;
ListData.DataBind();
}
"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I am sorry. I am using this on a web form. I have tried using the datalist
component and it tries to put the data into a table form as well. I would
assume that the repeater control will do the same. Is there an easy way to
get this info into a list box in a tabular format?

"Michael Mayer [C# MVP]" <mi**@mag37.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
First, are you using a windows or web application?

For windows forms apps:
ListView might do what you want

For customizing the datagrid, see:
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp

For web apps:
Repeater control
DataList control
--
Mike Mayer, C# MVP
mi**@mag37.com
http://www.mag37.com/csharp/
"Jeremy Ames" <yo******@here.com> wrote in message
news:eo**************@TK2MSFTNGP10.phx.gbl...
I am trying to use a datagrid to pull information from a database. I

prefer
to use latebinding to this. Well, I finally got my information to populate the datagrid, but the information came out in a table format. Is there a

way
that I can make the datagrid use list box or some other kind of grid?
Perhaps I am using the wrong components. Someone please help.


Nov 15 '05 #4

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

Similar topics

2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
0
by: Dave | last post by:
Tried posting in the Winform Forum without much luck, so posting here... After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is...
2
by: Ken Tucker | last post by:
I've read about this issue in many articles across the net... But haven't found a solution. I see all kinds of custom code to perform sorting with datagrids, but my example is so simple, I must...
2
by: Andy Fish | last post by:
Hi, I have some data which is stored as an array (or possibly an arraylist) of identically typed objects, each of which has certain public properties. I want to display these in a datagrid...
2
by: Axel Dahmen | last post by:
Hi, I'm using a DataGrid control to show a table's content with paging. For navigation through the pages I'm using the DataGrid's intrinsic navigation section. My problem: The DataGrid...
12
by: TB | last post by:
Hi All: I am trying to create a variation on the standard datagrid, whereby the datagrid is only shown after pressing some buttons. This reason for this is that I would like to use the same...
1
by: kingster | last post by:
Hi, I have a regular dataset and all i want to do is make a pivot table display in a browser with the datasource of the pivot table to be this dataset and then the end-user will be able to do...
0
by: pedaammulu | last post by:
Hi All, New title for Mastering Web Application Development. All secrets of developing an Accounting Software for the web revealed. Title: "Develop your own Web Accounting Application...
3
by: rn5a | last post by:
A SqlDataReader is populated with the records from a SQL Server 2005 DB table. The records retrieved depends upon 2 conditions (the conditions depend on what a user selects in an ASPX page). If...
1
nateraaaa
by: nateraaaa | last post by:
While working on a recent project I discovered how useful the CommandArgument property can be. I needed to determine the record_id of a row displayed in my datagrid. When the user clicked the Edit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.