Re: DropDownList Databind getting headers
- From: "tshad" <tscheiderich@xxxxxxxxxxxxxxx>
- Date: Tue, 28 Feb 2006 16:15:36 -0800
"Leon Friesema" <leon.friesema@xxxxxxxxxxxx> wrote in message
news:l6m902l38fmfbf1fdcqi3snutqs4sv3j1u@xxxxxxxxxx
On Tue, 28 Feb 2006 11:55:02 -0800, "tshad"
<tscheiderich@xxxxxxxxxxxxxxx> 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
.
- Follow-Ups:
- Re: DropDownList Databind getting headers
- From: Leon Friesema
- Re: DropDownList Databind getting headers
- References:
- Re: DropDownList Databind getting headers
- From: Leon Friesema
- Re: DropDownList Databind getting headers
- Prev by Date: Re: Dynamic code execution at run-time?
- Next by Date: Re: How to WriteXML as hierarchical XML
- Previous by thread: Re: DropDownList Databind getting headers
- Next by thread: Re: DropDownList Databind getting headers
- Index(es):
Relevant Pages
|