Monday, August 16, 2010

How do i select a gridview row, send it to another page, then update it, and return it to the gridview?

I guess you are talking about in Visual Studio. What you need to do is in the GridView page use the code similar to this to pick up one of the unique fields ( like product number in this example is row 1) and then send it to a new page ( in this example it's a page called ProductForm ) :





=======


Protected Sub gvProducts_


SelectedIndexChanged_


(ByVal sender As Object, ByVal e As System.EventArgs) _


Handles gvProducts.SelectedIndexChanged


Dim strMovexCode As String


strMovexCode = _


Trim(gvProducts.SelectedRow._


Cells(1).Text)


Response.Redirect(';ProductForm.aspx?pcp=鈥?%26amp; strMovexCode)


End Sub


=======





I have added this so that it runs when you select an item in the gridview but you can instead add it to a button if you want.





Then, in your page ( ProductForm in this example ) add the following to the Page Load to bring up the information in a field ( PRODUCT_CODE in this example ):





=======


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


If Not Page.IsPostBack Then


If Request.QueryString(';pcp';) %26lt;%26gt; ';'; Then


txtPRODUCT_CODE.Text = Request.QueryString(';pcp';)


End If


End If


Form.DataBind()


End Sub





=======





Sorry this is hard to explain but I hope that this helps. At least you will now have the keywords to search on.How do i select a gridview row, send it to another page, then update it, and return it to the gridview?
You need more detail in your question. What application is this?

No comments:

Post a Comment