I'm using a ListView and a F开发者_Python百科ormView in different pages.
What I need is to be able to click on one of the records and show the FormView with that record to update it. Is that possible?
Thanks
In the ListView you will need to make the field you want to click on a HyperLink field. The NavigateUrl
will then contain a link to the page you need to go to, and also pass a value using the QueryString to the page for example ?Id={value}
.
The recieving page will then retrieve the value from the QueryString and you will need to recreate the datasource, and retrieve the data only for the value passed in the QueryString and rebind the FormView
In response to the comment
From code behind you can retrieve the QueryString in your load method:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!String.IsNullOrEmpty(this.Request.QueryString[{VariableName]))
{
string someVariable = this.Request.QueryString[{VariableName}];
}
}
}
Alternatively you can do this in the HTML if your using a SqlDataSource
provider or similiar in the parameters collection for the select statement.
<asp:sqldatasource id="test" runat="server">
<selectparameters>
<asp:querystringparameter querystringfield="{VariableName}" name="someVariable" />
</selectparameters>
</asp:sqldatasource>
You can find more on the latter on MSDN here
Usually when passing details between forms i overide the form's constructor with a value that i can assign. What are you using to bind the information? Let me know if you need more info
If its asp.net you can send info as session state, or in query string etc
精彩评论