2
  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);
    }
}
1
  • Note that doing this causes the SELECT command to run twice (in the usual databind and in your code to explicitly call it again) - which will be inefficient if the query is heavy. Commented Jul 21, 2018 at 13:47

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks , currently i am doing as you said in some more complicated pages and now i need that modifications for some simpler report pages that i use only sqldatasource and objectdatasources in a simple way

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.