GridView-FormView (Master/Detail) Control not working...

GridView-FormView (Master/Detail) Control not working...

am 28.01.2008 11:58:15 von yixiang

Hi All,

I am a newbie to .NET programming and have been figuring out this
(master/detail) control.

However, it is not working...can someone please help me out???

ForeColor="#333333" GridLines="None"
Height="81px" Width="16px">
ForeColor="White" />


HeaderText="VersionNum" ReadOnly="True" SortExpression="VersionNum" />
HeaderText="ServiceID" ReadOnly="True" SortExpression="ServiceID" />
HeaderText="VersionDesc" SortExpression="VersionDesc" />



ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString2.
ProviderName %>" SelectCommand="SELECT [ServiceID], [VersionNum],
[VersionDesc] FROM [w_ServiceVersion]">





DataKeyNames="ServiceID,VersionNum" DataSourceID="SqlDataSource2"
Width="555px">

...........


.............



............


ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.
ProviderName %>" SelectCommand="SELECT ServiceID, VersionNum, VersionDesc
FROM dbo.w_ServiceVersion WHERE (ServiceID = ServiceID AND VersionNum =
VersionNum)">

Name="ServiceID" PropertyName="SelectedValue" />
Name="VersionNum" PropertyName="SelectedValue" />



url:http://ureader.com/gp/1417-1.aspx

RE: GridView-FormView (Master/Detail) Control not working...

am 29.01.2008 01:31:01 von mily242

Howdy,

Seems you use composite data key on columns ServiceID and VersionNum, but
you two control parameters both point to the first value which in this case
is ServiceID (you can check what's passed to the query by handling
SqlDataSource2.Selecting event and checking e.Command.Parameters[0].Value,
e.Command.Parameters[1].Value). They point to the same value because of you
used GridView1.SelectedValue property which is a shortcut for
GridView1.SelectedDataKey.Values[0], what you need is to change the code to:

ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT ServiceID, VersionNum, VersionDesc FROM
dbo.w_ServiceVersion WHERE (ServiceID = ServiceID AND VersionNum =
VersionNum)">

PropertyName="SelectedDataKey[0]" />
PropertyName="SelectedDataKey[1]" />



Hope this helps
--
Milosz


"yixiang" wrote:

> Hi All,
>
> I am a newbie to .NET programming and have been figuring out this
> (master/detail) control.
>
> However, it is not working...can someone please help me out???
>
> > ForeColor="#333333" GridLines="None"
> Height="81px" Width="16px">
> > ForeColor="White" />
>
>
> > HeaderText="VersionNum" ReadOnly="True" SortExpression="VersionNum" />
> > HeaderText="ServiceID" ReadOnly="True" SortExpression="ServiceID" />
> > HeaderText="VersionDesc" SortExpression="VersionDesc" />
>

>

>
> > ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
> ProviderName="<%$ ConnectionStrings:ConnectionString2.
> ProviderName %>" SelectCommand="SELECT [ServiceID], [VersionNum],
> [VersionDesc] FROM [w_ServiceVersion]">
>

>
>
>
>
> > DataKeyNames="ServiceID,VersionNum" DataSourceID="SqlDataSource2"
> Width="555px">
>
> ...........
>

>
> .............
>
>

>
> ............
>

>

> > ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
> ProviderName="<%$ ConnectionStrings:ConnectionString.
> ProviderName %>" SelectCommand="SELECT ServiceID, VersionNum, VersionDesc
> FROM dbo.w_ServiceVersion WHERE (ServiceID = ServiceID AND VersionNum =
> VersionNum)">
>
> > Name="ServiceID" PropertyName="SelectedValue" />
> > Name="VersionNum" PropertyName="SelectedValue" />
>

>

>
> url:http://ureader.com/gp/1417-1.aspx
>