how to rowfilter a row using textbox for date and time or only date ?
plsss help

i am getting error with this code
dv.RowFilter = "Date = '" +textBox1.Text.ToString()+"'";

thanks :)

Recommended Answers

What error are you getting?

Jump to Post

All 4 Replies

What error are you getting?

knowing the error you're getting would help a lot. As a side note, you don't need to use .ToString() on the Text property of a textbox control, it's already a string.

Is it date formatting error? try to use date formats.

Ill try posting again as the last one is nt showing?

you could try formatting times and dates like so...

DateTime thisDate1 = new DateTime(2011, 6, 10);
Console.WriteLine("Today is " + thisDate1.ToString("MMMM dd, yyyy") + ".");

notice the single quotes in the example below...

private void MakeDataView() 
    DataView view = new DataView();

    view.Table = DataSet1.Tables["Suppliers"];
    view.AllowDelete = true;
    view.AllowEdit = true;
    view.AllowNew = true;
    view.RowFilter = "City = 'Berlin'";
    view.RowStateFilter = DataViewRowState.ModifiedCurrent;
    view.Sort = "CompanyName DESC";

    // Simple-bind to a TextBox control
    Text1.DataBindings.Add("Text", view, "CompanyName");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.