If for any reason you want to set your ASP.NET 2.0 SqlDataSource parameter programmatically before executing, you can use the Selecting event as show in the following code:
1: Partial Class Default2
2: Inherits System.Web.UI.Page
3:
4: Dim strRegion As String
5: Dim strSubgerencia As String
6: Dim strCentral As String
7: Dim strUnidad As String
8: Dim strSistema As String
9: Dim strTipoEquipo As String
10: Dim strConsecutivo As String
11: Dim strMedidor As String
12:
13: Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
14:
15: ' get some info from the current selected row
16: strSistema = Me.GridView1.SelectedRow.Cells(2).Text
17: strTipoEquipo = Me.GridView1.SelectedRow.Cells(3).Text
18: strConsecutivo = Me.GridView1.SelectedRow.Cells(4).Text
19: strMedidor = Me.GridView1.SelectedRow.Cells(5).Text
20:
21: ' fire up the details control
22: Me.FormView1.DataBind()
23: End Sub
24:
25: Protected Sub SqlDataSource6_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource6.Selecting
26:
27: ' get more data from other controls in the form
28: strRegion = Me.DropDownList1.SelectedValue
29: strSubgerencia = Me.DropDownList2.SelectedValue
30: strCentral = Me.DropDownList3.SelectedValue
31: strUnidad = Me.DropDownList4.SelectedValue
32:
33: ' set the command parameters of a particular SqlDataSource
34: e.Command.Parameters("@Region").Value = strRegion 35: e.Command.Parameters("@Subgerencia").Value = strSubgerencia 36: e.Command.Parameters("@Central").Value = strCentral 37: e.Command.Parameters("@Unidad").Value = strUnidad 38: e.Command.Parameters("@sistema").Value = strSistema 39: e.Command.Parameters("@tipoequipo").Value = strTipoEquipo 40: e.Command.Parameters("@consecutivo").Value = strConsecutivo 41: e.Command.Parameters("@medidor").Value = strMedidor 42:
43: End Sub
44: End Class
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }