Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ObjectDataSource nulling GridView

Reply
Thread Tools

ObjectDataSource nulling GridView

 
 
tshad
Guest
Posts: n/a
 
      02-04-2010
I have a GridView object that is using an ObjectDataSource, but when I get I
do a GridView1.DataBind(), the following method gets called:

<asp:ObjectDataSource ID="ObjectDataSource1" EnablePaging="true"
runat="server" SelectCountMethod="GetRowCount"
SelectMethod="BindControl" TypeName="AutoUPS.AutoUPS"
StartRowIndexParameterName="startRowIndex"
MaximumRowsParameterName="maximumRows">
</asp:ObjectDataSource>


public DataTable BindControl(int startRowIndex, int maximumRows)
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["ConnectString"].ConnectionString);
SqlCommand com = new SqlCommand("GetValidFileDetails2", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add("@RowIndex", SqlDbType.Int, 4).Value =
startRowIndex;
com.Parameters.Add("@MaxRows", SqlDbType.Int, 4).Value =
maximumRows;
SetData(ObjectDataSource1);

SqlDataAdapter ada = new SqlDataAdapter(com);

DataTable dt = new DataTable();
ada.Fill(dt);
return dt;
}

At this point both GridView1 and ObjectDataSource1 are null????

They weren't before when I did my GridView1.DataBind() and they weren't when
I went into my PageLoad.

So because of that I can't pass ObjectDataSource1 to my SetData program from
this method.

Why is that?

Thanks,

Tom



 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      02-05-2010
It is almost as if I have left the object.

But the BindControl method is in the page and if I put a break in the
method, it sees the GridView1 it just happens to be null.

Tom
"tshad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a GridView object that is using an ObjectDataSource, but when I get
>I do a GridView1.DataBind(), the following method gets called:
>
> <asp:ObjectDataSource ID="ObjectDataSource1" EnablePaging="true"
> runat="server" SelectCountMethod="GetRowCount"
> SelectMethod="BindControl" TypeName="AutoUPS.AutoUPS"
> StartRowIndexParameterName="startRowIndex"
> MaximumRowsParameterName="maximumRows">
> </asp:ObjectDataSource>
>
>
> public DataTable BindControl(int startRowIndex, int maximumRows)
> {
> SqlConnection con = new
> SqlConnection(ConfigurationManager.ConnectionStrin gs["ConnectString"].ConnectionString);
> SqlCommand com = new SqlCommand("GetValidFileDetails2", con);
> com.CommandType = CommandType.StoredProcedure;
> com.Parameters.Add("@RowIndex", SqlDbType.Int, 4).Value =
> startRowIndex;
> com.Parameters.Add("@MaxRows", SqlDbType.Int, 4).Value =
> maximumRows;
> SetData(ObjectDataSource1);
>
> SqlDataAdapter ada = new SqlDataAdapter(com);
>
> DataTable dt = new DataTable();
> ada.Fill(dt);
> return dt;
> }
>
> At this point both GridView1 and ObjectDataSource1 are null????
>
> They weren't before when I did my GridView1.DataBind() and they weren't
> when I went into my PageLoad.
>
> So because of that I can't pass ObjectDataSource1 to my SetData program
> from this method.
>
> Why is that?
>
> Thanks,
>
> Tom
>
>
>



 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      02-05-2010
As it turns out all the objects on my page are null???

Tom

"tshad" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> It is almost as if I have left the object.
>
> But the BindControl method is in the page and if I put a break in the
> method, it sees the GridView1 it just happens to be null.
>
> Tom
> "tshad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I have a GridView object that is using an ObjectDataSource, but when I get
>>I do a GridView1.DataBind(), the following method gets called:
>>
>> <asp:ObjectDataSource ID="ObjectDataSource1" EnablePaging="true"
>> runat="server" SelectCountMethod="GetRowCount"
>> SelectMethod="BindControl" TypeName="AutoUPS.AutoUPS"
>> StartRowIndexParameterName="startRowIndex"
>> MaximumRowsParameterName="maximumRows">
>> </asp:ObjectDataSource>
>>
>>
>> public DataTable BindControl(int startRowIndex, int maximumRows)
>> {
>> SqlConnection con = new
>> SqlConnection(ConfigurationManager.ConnectionStrin gs["ConnectString"].ConnectionString);
>> SqlCommand com = new SqlCommand("GetValidFileDetails2", con);
>> com.CommandType = CommandType.StoredProcedure;
>> com.Parameters.Add("@RowIndex", SqlDbType.Int, 4).Value =
>> startRowIndex;
>> com.Parameters.Add("@MaxRows", SqlDbType.Int, 4).Value =
>> maximumRows;
>> SetData(ObjectDataSource1);
>>
>> SqlDataAdapter ada = new SqlDataAdapter(com);
>>
>> DataTable dt = new DataTable();
>> ada.Fill(dt);
>> return dt;
>> }
>>
>> At this point both GridView1 and ObjectDataSource1 are null????
>>
>> They weren't before when I did my GridView1.DataBind() and they weren't
>> when I went into my PageLoad.
>>
>> So because of that I can't pass ObjectDataSource1 to my SetData program
>> from this method.
>>
>> Why is that?
>>
>> Thanks,
>>
>> Tom
>>
>>
>>

>
>



 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      02-05-2010
It seems these methods have no access to the objects on the page, for some
reason. You have to set up Select parameters to access basic data in the
method (int,string).

<SelectParameters>
<asp:ControlParameter ControlID="ddlProcessJobsClient" Name="clientID"
PropertyName="SelectedValue" Type="String" DefaultValue="1" />
</SelectParameters>

The problem is that I need to get access to a small Grid that has some
dropdowns in them. I go through the dropdowns to get data I append to a
string and send as a parameter to my stored procedure. But I can't get
access to my Grid. I have a method on my page that will get the data for
me, but I can't get to that either. And there is no way (that I can see) to
use the SelectParameters to pass the Grid as it isn't a simple type.

Tom

"tshad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> As it turns out all the objects on my page are null???
>
> Tom
>
> "tshad" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> It is almost as if I have left the object.
>>
>> But the BindControl method is in the page and if I put a break in the
>> method, it sees the GridView1 it just happens to be null.
>>
>> Tom
>> "tshad" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I have a GridView object that is using an ObjectDataSource, but when I
>>>get I do a GridView1.DataBind(), the following method gets called:
>>>
>>> <asp:ObjectDataSource ID="ObjectDataSource1" EnablePaging="true"
>>> runat="server" SelectCountMethod="GetRowCount"
>>> SelectMethod="BindControl" TypeName="AutoUPS.AutoUPS"
>>> StartRowIndexParameterName="startRowIndex"
>>> MaximumRowsParameterName="maximumRows">
>>> </asp:ObjectDataSource>
>>>
>>>
>>> public DataTable BindControl(int startRowIndex, int maximumRows)
>>> {
>>> SqlConnection con = new
>>> SqlConnection(ConfigurationManager.ConnectionStrin gs["ConnectString"].ConnectionString);
>>> SqlCommand com = new SqlCommand("GetValidFileDetails2", con);
>>> com.CommandType = CommandType.StoredProcedure;
>>> com.Parameters.Add("@RowIndex", SqlDbType.Int, 4).Value =
>>> startRowIndex;
>>> com.Parameters.Add("@MaxRows", SqlDbType.Int, 4).Value =
>>> maximumRows;
>>> SetData(ObjectDataSource1);
>>>
>>> SqlDataAdapter ada = new SqlDataAdapter(com);
>>>
>>> DataTable dt = new DataTable();
>>> ada.Fill(dt);
>>> return dt;
>>> }
>>>
>>> At this point both GridView1 and ObjectDataSource1 are null????
>>>
>>> They weren't before when I did my GridView1.DataBind() and they weren't
>>> when I went into my PageLoad.
>>>
>>> So because of that I can't pass ObjectDataSource1 to my SetData program
>>> from this method.
>>>
>>> Why is that?
>>>
>>> Thanks,
>>>
>>> Tom
>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nulling an object Frank Cisco Java 35 05-20-2009 11:49 AM
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
ObjectDataSource method as another ObjectDataSource David Thielen ASP .Net Web Controls 3 03-23-2006 01:50 AM
GridView update with ObjectDataSource Danny W ASP .Net 0 09-08-2005 06:30 AM
xpo objectdatasource gridview detailview Kha Tran ASP .Net 0 06-03-2005 09:22 AM



Advertisments