indhu arun 0 Newbie Poster

For the last two days I was banging my head to move the control to a specific record in a formview(that is used to update a specific record based on the primary key selected in a dropdown). I use asp.net 3.5 and Linq.. so using Linqdatasource I couldn't find a way to implement this. After long struggle i got it working, thought of sharing it if anybody needs it in future.
I Wrote this in the page_load event, may include ispostback if needed, for me it works without that.


myObject is my custom object
Part and Dash are my keys for that table
I have those values in session.

Hope this help someone.

Indhu S

FormViewRow row = FormViewComponents.Row;
        for (int i = 0; i < FormViewComponents.DataItemCount - 1; i++)
        {
            if (FormViewComponents.DataItem != null)
            {
                if (((myObject)FormViewComponents.DataItem).Part == Session["part"].ToString() && ((myObject)FormViewComponents.DataItem).Dash == Session["dash"].ToString())
                {
                    FormViewComponents.PageIndex = i;
                    break;
                }
                else
                {
                    FormViewComponents.PageIndex = FormViewComponents.PageIndex + 1;
                    FormViewComponents.DataBind();
                }
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.