Datasource in MultiView

B

Bryce

Not sure how to word this, so if it seems like I'm rambling, sorry..

I have a MultiView object on my form, with a Grid showing a list, with
"Edit", "Select" and "Delete" links. Here's the definition:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="ArticleViewDataSource"
OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:BoundField DataField="ArticleTitle"
HeaderText="ArticleTitle" SortExpression="ArticleTitle" />
</Columns>
</asp:GridView>

Now, as you can see, I have an event handler handling the "OnRowCommand"
event. That method basically changes the view to one that contains a
FormView.

protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
articleSelectedValue = int.Parse(
MultiView1.SetActiveView(ArticleEditView);
}

The FormView's datasource has a parameter that I have bound to the GridView
control like so:
<asp:ObjectDataSource ID="ArticleDataSource" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetArticleByArticleId"
TypeName="NewsArticleManager">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1"
DefaultValue="0" Name="articleId" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>

This doesn't seem to work though. The view changes correctly, but the
articleId being passed is a 0, and thereby displaying nothing.

When I inspect the value of GridView1.SelectedValue on the event handler, it
is null. Not sure if that is the best way to do that.

Any suggestions would be appreciated.
 
M

Masudur

Not sure how to word this, so if it seems like I'm rambling, sorry..

I have a MultiView object on my form, with a Grid showing a list, with
"Edit", "Select" and "Delete" links. Here's the definition:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="ArticleViewDataSource"
OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:BoundField DataField="ArticleTitle"
HeaderText="ArticleTitle" SortExpression="ArticleTitle" />
</Columns>
</asp:GridView>

Now, as you can see, I have an event handler handling the "OnRowCommand"
event. That method basically changes the view to one that contains a
FormView.

protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
articleSelectedValue = int.Parse(
MultiView1.SetActiveView(ArticleEditView);
}

The FormView's datasource has a parameter that I have bound to the GridView
control like so:
<asp:ObjectDataSource ID="ArticleDataSource" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetArticleByArticleId"
TypeName="NewsArticleManager">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1"
DefaultValue="0" Name="articleId" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>

This doesn't seem to work though. The view changes correctly, but the
articleId being passed is a 0, and thereby displaying nothing.

When I inspect the value of GridView1.SelectedValue on the event handler, it
is null. Not sure if that is the best way to do that.

Any suggestions would be appreciated.

Hi...

do it manually
onrowcommad get the articleid and then
use it to populate the from view....
even though its not that good... but for now it will save you...

Thanks
Masudur
 
B

Bryce

Masudur said:
Hi...

do it manually
onrowcommad get the articleid and then
use it to populate the from view....
even though its not that good... but for now it will save you...

Thanks. I think I got it working, but I'm not entirely sure what I did...

Now, I'm trying to do the same with a Bulleted List..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top