Re: DropDownList Databind getting headers

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"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


.



Relevant Pages

  • Re: DropDownList Databind getting headers
    ... "Pay Date". ... The first "for loop" is creating the columns and the second loop creates ... The first loop takes the Data I pass in the .Add method and uses that for ... the Column Headings. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: DropDownList Databind getting headers
    ... "Pay Date". ... The first "for loop" is creating the columns and the second loop creates the ... the Column Headings. ...
    (microsoft.public.dotnet.languages.csharp)
  • i cant seem to figure something simple out
    ... Use a constructor to initialize the employee information, ... and a method within that class to calculate the weekly pay. ... double payrate; ... {// Start of name while loop ...
    (comp.lang.java.help)
  • Re: OT-Wonder if Nothermark shops Walmart?
    ... Group, one of the city?s most powerful lobby shops, which has ... Wal Mart only offers VALUE that Americans want. ... to pay significantly more for their products are FREE to pay union ... you yap and yap about not closing the loop. ...
    (rec.outdoors.rv-travel)
  • [SLE] a few Kmail oddities
    ... Autofill addresses time out to quickly ... Kmail "knows" addresses I have used before. ... How do I get firefox to open them and not loop. ... Unless you pay nothing, then you get more. ...
    (SuSE)