Un Request.QueryString in un DetailsView

lunedì 22 novembre 2010 - 23.25
Tag Elenco Tags  C#  |  .NET 2.0  |  Windows XP  |  Visual Studio 2005

paolo973 Profilo | Senior Member

Ho pagina1.aspx contenente un oggetto HyperLink

<asp:HyperLink ID="HyperLink1" NavigateUrl="~/pagina2.aspx?id=77" runat="server" >link</asp:HyperLink>

in pagina2.aspx ho un oggetto DataList ed un DetailsView così fatto:

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="id"
DataSourceID="AccessDataSource2"
...
SelectCommand="SELECT * FROM [tbl] WHERE ([id] = ?)"
...
<SelectParameters>
<asp:ControlParameter ControlID="DataList1" Name="id" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
...
</asp:DetailsView>

DOMANDA:

quando arrivo in pagina2.aspx?id=33, per esempio, desidero che nel DetailsView abbia il record con id = 33.

Come fare ?

devo lavorare nel pagina2.aspx.cs ? oppure altro ?

protected void Page_Load(object sender, EventArgs e)
{
int id = Convert.ToInt16(Request.QueryString["id"]);
this.DetailsView1...

}

sankyu Profilo | Senior Member

ho impostato l'evento onDataBinding=DvDataBinding lato ASP e poi ho creato questo
protected void DvDataBinding(object sender, EventArgs e)
{
if (Request.QueryString["id"] != null)
ObjectDataSource1.SelectParameters["nomeParametro"].DefaultValue = Request.QueryString["id"];
}
dovrebbe andare


Consulente e Sviluppatore .net in ambito finanziario
Dai un occhio al mio blog potrebbe tornarti utile
http://dotnetmemo.blogspot.com
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5