C
cmrchs
Hello,
I have a GridView and an objectDataSource
<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1" AllowPaging="True" />
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
TypeName="ProductsLib.Business.ProductsBLO"
SelectMethod="SelectProducts"
SortParameterName="sortExpression"></asp:ObjectDataSource>
When I run the app i see a list of products in the gridView. Ok!
Now, i have a button, when I click on it I'd like to display all the
products whose ProductName starts with the letter 'c'
My implementation in the clickevent handler:
DataTable dataTable = GridView1.DataSource as DataTable;
if (dataTable != null)
{
DataView dataView = new DataView(dataTable);
dataView.RowFilter = "productname like 'c%'";
dataView.Sort = "productname";
GridView1.DataSource = dataView;
GridView1.DataBind();
}
but my problem is that GridView1.DataSource is null ???
how do i obtain acces to the dataTable?
thank you
Chris
I have a GridView and an objectDataSource
<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1" AllowPaging="True" />
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
TypeName="ProductsLib.Business.ProductsBLO"
SelectMethod="SelectProducts"
SortParameterName="sortExpression"></asp:ObjectDataSource>
When I run the app i see a list of products in the gridView. Ok!
Now, i have a button, when I click on it I'd like to display all the
products whose ProductName starts with the letter 'c'
My implementation in the clickevent handler:
DataTable dataTable = GridView1.DataSource as DataTable;
if (dataTable != null)
{
DataView dataView = new DataView(dataTable);
dataView.RowFilter = "productname like 'c%'";
dataView.Sort = "productname";
GridView1.DataSource = dataView;
GridView1.DataBind();
}
but my problem is that GridView1.DataSource is null ???
how do i obtain acces to the dataTable?
thank you
Chris