T
tshad
Here is my SqlDataSource. You can see that I have a SelectCommand,
onSelecting and onDataBinding.
<asp:SqlDataSource ID="SqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectString %>"
SelectCommand="GetResponseFileExceptions"
SelectCommandType="StoredProcedure"
OnSelecting="SqlDataSource_Selecting"
OnDataBinding="SqlDataSource_DataBinding"
UpdateCommand="UpdateDummy"
UpdateCommandType="StoredProcedure">
</asp:SqlDataSource>
In my GridView, I have:
<asp:GridView ID="GridView1"
DataSourceID="SqlDataSource"
AutoGenerateColumns="False"
SkinID="mGridViewSkin"
CssClass="Grid100"
AllowPaging="True"
AllowSorting="True"
PageSize="15"
PagerSettings-Mode="NumericFirstLast"
PagerStyle-CssClass="GridViewPager"
OnPageIndexChanged="mGridView_PageIndexChanged"
OnRowEditing="GridView1_RowEditing"
OnRowDataBound="ItemDataBoundEventHandler1"
OnRowUpdating="GridView1_RowUpdating"
runat="server">
In my code I have the following:
protected void SqlDataSource_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
SqlDataSource.SelectParameters.Clear();
SqlDataSource.SelectParameters.Add("ClientID", TypeCode.Int32,
"36");
}
protected void SqlDataSource_DataBinding(object sender, EventArgs e)
{
}
When I initially run my page, the SelectCommand is executed. But before it
executes it calls the SqlDataSource_Selecting event where it adds a
parameter. I can tell by looking at the Profiler that the command is not
sent to Sql until after the parameter is added. But the Store Procedure is
sent without the parameter.
When I press the page number at the bottom of the grid it again goes to the
SqlDataSource_Selecting procedure and this time it calls the Stored
Procedure with the parameter.
Why didn't the parameter get sent on the first call? It was set.
Also, what caused the command to be set at all?
I never did a databind.
Also, I have an event set for onDataBinding, but it never gets called. Why
is that?
Thanks,
Tom
onSelecting and onDataBinding.
<asp:SqlDataSource ID="SqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectString %>"
SelectCommand="GetResponseFileExceptions"
SelectCommandType="StoredProcedure"
OnSelecting="SqlDataSource_Selecting"
OnDataBinding="SqlDataSource_DataBinding"
UpdateCommand="UpdateDummy"
UpdateCommandType="StoredProcedure">
</asp:SqlDataSource>
In my GridView, I have:
<asp:GridView ID="GridView1"
DataSourceID="SqlDataSource"
AutoGenerateColumns="False"
SkinID="mGridViewSkin"
CssClass="Grid100"
AllowPaging="True"
AllowSorting="True"
PageSize="15"
PagerSettings-Mode="NumericFirstLast"
PagerStyle-CssClass="GridViewPager"
OnPageIndexChanged="mGridView_PageIndexChanged"
OnRowEditing="GridView1_RowEditing"
OnRowDataBound="ItemDataBoundEventHandler1"
OnRowUpdating="GridView1_RowUpdating"
runat="server">
In my code I have the following:
protected void SqlDataSource_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
SqlDataSource.SelectParameters.Clear();
SqlDataSource.SelectParameters.Add("ClientID", TypeCode.Int32,
"36");
}
protected void SqlDataSource_DataBinding(object sender, EventArgs e)
{
}
When I initially run my page, the SelectCommand is executed. But before it
executes it calls the SqlDataSource_Selecting event where it adds a
parameter. I can tell by looking at the Profiler that the command is not
sent to Sql until after the parameter is added. But the Store Procedure is
sent without the parameter.
When I press the page number at the bottom of the grid it again goes to the
SqlDataSource_Selecting procedure and this time it calls the Stored
Procedure with the parameter.
Why didn't the parameter get sent on the first call? It was set.
Also, what caused the command to be set at all?
I never did a databind.
Also, I have an event set for onDataBinding, but it never gets called. Why
is that?
Thanks,
Tom