473,395 Members | 1,368 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,395 software developers and data experts.

DropDownList Databind getting headers

I have a DataTable which has the headings in row 0.

I do the following:

PayDates.DataSource=mDt;
PayDates.DataTextField= "Pay Date";
PayDates.DataValueField="Pay Date";
PayDates.DataBind();
PayDates.Items.Insert(0, "Select Date");

But when I look at the DropdownList, the 2nd item, after "Select Date", is
"Pay Date".

How do I tell it not to use row 0?

It obviously knows row 0 is the header row as it uses that to figure out
which column in the table to use.

Thanks,

Tom
Feb 28 '06 #1
4 3646
On Tue, 28 Feb 2006 11:55:02 -0800, "tshad"
<ts**********@ftsolutions.com> wrote:
I have a DataTable which has the headings in row 0.

I do the following:

PayDates.DataSource=mDt;
PayDates.DataTextField= "Pay Date";
PayDates.DataValueField="Pay Date";
PayDates.DataBind();
PayDates.Items.Insert(0, "Select Date");

But when I look at the DropdownList, the 2nd item, after "Select Date", is
"Pay Date".

How do I tell it not to use row 0?

It obviously knows row 0 is the header row as it uses that to figure out
which column in the table to use.

Thanks,

Tom


Tom,

what do you mean by 'headings' ?
A datatable has columns (like 'Pay Date' --> which, for obvious
reasons should be called 'PayDate'). You bind the dataset to the
control by it's column name.

Further more: "How do I tell it not to use row 0?"
I guess you mean, that "Select Date" is an invalid option but should
be visible by default?

greetz,
Leon
Feb 28 '06 #2
"Leon Friesema" <le***********@frostbits.nl> wrote in message
news:l6********************************@4ax.com...
On Tue, 28 Feb 2006 11:55:02 -0800, "tshad"
<ts**********@ftsolutions.com> wrote:
I have a DataTable which has the headings in row 0.

I do the following:

PayDates.DataSource=mDt;
PayDates.DataTextField= "Pay Date";
PayDates.DataValueField="Pay Date";
PayDates.DataBind();
PayDates.Items.Insert(0, "Select Date");

But when I look at the DropdownList, the 2nd item, after "Select Date", is
"Pay Date".

How do I tell it not to use row 0?

It obviously knows row 0 is the header row as it uses that to figure out
which column in the table to use.

Thanks,

Tom

Tom,

what do you mean by 'headings' ?
A datatable has columns (like 'Pay Date' --> which, for obvious
reasons should be called 'PayDate'). You bind the dataset to the
control by it's column name.


My table, similar to what you get back from an sql query, has the title of
the column in row 0 (how else would the value and text field work).

PayDates.DataTextField= "Pay Date";

I assume that if I didn't have "Pay Date" in one of the columns in row 0, it
wouldn't be able to do the above command. If I were to bind this to a
datagrid, it is actually putting the row 0 twice (once for the Heading and
once for the 1st row). Not sure why that is, unless there is a way to tell
the datatable that this is a Heading.

I may not be creating the table correctly.

Here is how I am creating the Table:

for(ktr=0;ktr<= rtDataBean.stringArray[0].GetUpperBound(0);ktr++)
{
mDt.Columns.Add(new DataColumn(rtDataBean.stringArray[0][ktr]));
};

for(ktr=0;ktr<= rtDataBean.stringArray.GetUpperBound(0);ktr++)
{
DataRow mDr = mDt.NewRow();
for (ktr1=0;ktr1<=rtDataBean.stringArray[0].GetUpperBound(0);ktr1++)
{
mDr[ktr1] = rtDataBean.stringArray[ktr][ktr1];
};
mDr[ktr1] = rtDataBean.stringArray[ktr][payDateRow] + " / " +
rtDataBean.stringArray[ktr][postDateRow];
mDt.Rows.Add(mDr);
};

The first "for loop" is creating the columns and the second loop creates the
rows and puts the data in the columns.

I think I just figured it out.

I am using row 0 to create the columns for the table and then I am also
using row 0 in the 2nd loop again.

The first loop takes the Data I pass in the .Add method and uses that for
the Column Headings (I think).

Thanks,

Tom
Further more: "How do I tell it not to use row 0?"
I guess you mean, that "Select Date" is an invalid option but should
be visible by default?

greetz,
Leon

Mar 1 '06 #3
On Tue, 28 Feb 2006 16:15:36 -0800, "tshad"
<ts**********@ftsolutions.com> wrote:
"Leon Friesema" <le***********@frostbits.nl> wrote in message
news:l6********************************@4ax.com.. .
On Tue, 28 Feb 2006 11:55:02 -0800, "tshad"
<ts**********@ftsolutions.com> wrote:
I have a DataTable which has the headings in row 0.

I do the following:

PayDates.DataSource=mDt;
PayDates.DataTextField= "Pay Date";
PayDates.DataValueField="Pay Date";
PayDates.DataBind();
PayDates.Items.Insert(0, "Select Date");

But when I look at the DropdownList, the 2nd item, after "Select Date", is
"Pay Date".

How do I tell it not to use row 0?

It obviously knows row 0 is the header row as it uses that to figure out
which column in the table to use.

Thanks,

Tom


Tom,

what do you mean by 'headings' ?
A datatable has columns (like 'Pay Date' --> which, for obvious
reasons should be called 'PayDate'). You bind the dataset to the
control by it's column name.


My table, similar to what you get back from an sql query, has the title of
the column in row 0 (how else would the value and text field work).

PayDates.DataTextField= "Pay Date";

I assume that if I didn't have "Pay Date" in one of the columns in row 0, it
wouldn't be able to do the above command. If I were to bind this to a
datagrid, it is actually putting the row 0 twice (once for the Heading and
once for the 1st row). Not sure why that is, unless there is a way to tell
the datatable that this is a Heading.

I may not be creating the table correctly.

Here is how I am creating the Table:

for(ktr=0;ktr<= rtDataBean.stringArray[0].GetUpperBound(0);ktr++)
{
mDt.Columns.Add(new DataColumn(rtDataBean.stringArray[0][ktr]));
};

for(ktr=0;ktr<= rtDataBean.stringArray.GetUpperBound(0);ktr++)
{
DataRow mDr = mDt.NewRow();
for (ktr1=0;ktr1<=rtDataBean.stringArray[0].GetUpperBound(0);ktr1++)
{
mDr[ktr1] = rtDataBean.stringArray[ktr][ktr1];
};
mDr[ktr1] = rtDataBean.stringArray[ktr][payDateRow] + " / " +
rtDataBean.stringArray[ktr][postDateRow];
mDt.Rows.Add(mDr);
};

The first "for loop" is creating the columns and the second loop creates the
rows and puts the data in the columns.

I think I just figured it out.

I am using row 0 to create the columns for the table and then I am also
using row 0 in the 2nd loop again.

The first loop takes the Data I pass in the .Add method and uses that for
the Column Headings (I think).

Thanks,

Tom

Further more: "How do I tell it not to use row 0?"
I guess you mean, that "Select Date" is an invalid option but should
be visible by default?

greetz,
Leon


Tom,

start the second for-loop (ktr not ktr1) at 1 not 0, that should do
the trick or otherwise, don't perform the insert after databinding.

greetz,
Leon
Mar 1 '06 #4

"Leon Friesema" <le***********@frostbits.nl> wrote in message
news:13********************************@4ax.com...
On Tue, 28 Feb 2006 16:15:36 -0800, "tshad"
<ts**********@ftsolutions.com> wrote:
"Leon Friesema" <le***********@frostbits.nl> wrote in message
news:l6********************************@4ax.com. ..
On Tue, 28 Feb 2006 11:55:02 -0800, "tshad"
<ts**********@ftsolutions.com> wrote:

I have a DataTable which has the headings in row 0.

I do the following:

PayDates.DataSource=mDt;
PayDates.DataTextField= "Pay Date";
PayDates.DataValueField="Pay Date";
PayDates.DataBind();
PayDates.Items.Insert(0, "Select Date");

But when I look at the DropdownList, the 2nd item, after "Select Date",
is
"Pay Date".

How do I tell it not to use row 0?

It obviously knows row 0 is the header row as it uses that to figure out
which column in the table to use.

Thanks,

Tom
Tom,

what do you mean by 'headings' ?
A datatable has columns (like 'Pay Date' --> which, for obvious
reasons should be called 'PayDate'). You bind the dataset to the
control by it's column name.
My table, similar to what you get back from an sql query, has the title of
the column in row 0 (how else would the value and text field work).

PayDates.DataTextField= "Pay Date";

I assume that if I didn't have "Pay Date" in one of the columns in row 0,
it
wouldn't be able to do the above command. If I were to bind this to a
datagrid, it is actually putting the row 0 twice (once for the Heading and
once for the 1st row). Not sure why that is, unless there is a way to
tell
the datatable that this is a Heading.

I may not be creating the table correctly.

Here is how I am creating the Table:

for(ktr=0;ktr<= rtDataBean.stringArray[0].GetUpperBound(0);ktr++)
{
mDt.Columns.Add(new DataColumn(rtDataBean.stringArray[0][ktr]));
};

for(ktr=0;ktr<= rtDataBean.stringArray.GetUpperBound(0);ktr++)
{
DataRow mDr = mDt.NewRow();
for (ktr1=0;ktr1<=rtDataBean.stringArray[0].GetUpperBound(0);ktr1++)
{
mDr[ktr1] = rtDataBean.stringArray[ktr][ktr1];
};
mDr[ktr1] = rtDataBean.stringArray[ktr][payDateRow] + " / " +
rtDataBean.stringArray[ktr][postDateRow];
mDt.Rows.Add(mDr);
};

The first "for loop" is creating the columns and the second loop creates
the
rows and puts the data in the columns.

I think I just figured it out.

I am using row 0 to create the columns for the table and then I am also
using row 0 in the 2nd loop again.

The first loop takes the Data I pass in the .Add method and uses that for
the Column Headings (I think).

Thanks,

Tom

Further more: "How do I tell it not to use row 0?"
I guess you mean, that "Select Date" is an invalid option but should
be visible by default?

greetz,
Leon


Tom,

start the second for-loop (ktr not ktr1) at 1 not 0, that should do
the trick or otherwise, don't perform the insert after databinding.

That was it.

Thanks,

Tom greetz,
Leon

Mar 1 '06 #5

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

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
1
by: Ravi | last post by:
I am trying to represent master-detail records from a database The general logic will be populating the first dropdownlist with the master records and on change of the first dropdownlis getting...
1
by: Ravi | last post by:
I am trying to represent master-detail records from a database The general logic will be populating the first dropdownlist with the master records and on change of the first dropdownlis getting...
3
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would...
12
by: darrel | last post by:
I have a asp:dropdownlist set to autopostback. However, my handler doesn't seem to execute (even though there is a postback). Here's the DDL: <asp:dropdownlist id=ddl_districtSelect...
8
by: tshad | last post by:
Can you databind a dropdownlist to another dropdownlist? I have 2 identical list. I am getting my data from a DataReader, so as soon as I have bound the first DDL, I can't do it again to the next...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
1
by: mitchman10 | last post by:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours My Chargecode table has ChargecodeID,c_Text I need an Editable datagrid that will show the TimeID,Employee,PayPeriod,C_Text in a...
1
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList is...
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: 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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...

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.