Iman
Iman

Reputation: 18906

Modify sqldatasource selected data before binding?

  1. how can i access the my sqldatasource selected datasource for modification and adding for example new datacolumns before binding??

  2. where is the best place to perform these modifications ?

  3. I guess SqlDataSource1_Selected is the right place, but i don't know how ?

----------updated---------

I found how to to access the selected data to show the total record but my questions is still not solved

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        DataTable dt = ((DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty)).Table;
        LabelTotal.Text = string.Format("{0} items found", dt.Rows.Count);
    }
}

Upvotes: 2

Views: 1652

Answers (1)

Pankaj Agarwal
Pankaj Agarwal

Reputation: 11311

It will be better if you bind GridView using your custom code at .cs page rather than use SqlDataSource.

At .cs page you can perform your operation with datatable before bind gridview.

Upvotes: 2

Related Questions