Datasource in MultiView

Discussion in 'ASP .Net Web Controls' started by Bryce, Jun 23, 2007.

  1. Bryce

    Bryce Guest

    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.
    Bryce, Jun 23, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    511
  2. Stephen

    multiview without postback

    Stephen, Aug 2, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    7,000
    Stephen
    Aug 2, 2005
  3. Replies:
    7
    Views:
    5,928
  4. Bryce

    Datasource in MultiView

    Bryce, Jun 24, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    763
    Bryce
    Jun 24, 2007
  5. Andy B
    Replies:
    0
    Views:
    364
    Andy B
    Dec 29, 2008
Loading...

Share This Page