Advertisement
Advertisement
| 05.09.2008 at 02:15PM PDT, ID: 23390848 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: |
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<br />
<asp:Panel runat="server" ID="DropDown1Form">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
DataTextField="Description" DataValueField="Group_ID">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetAppsConnectionString %>"
SelectCommand="SELECT DISTINCT JSA_Groups.[Description], JSA_Groups.[Group_ID] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID = JSA_Groups_1.Parent ORDER BY JSA_Groups.[Description]">
</asp:SqlDataSource>
</asp:Panel>
<asp:Panel runat="server" ID="DropDown2Form" Visible="False">
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3"
DataTextField="Description" DataValueField="Group_ID">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetAppsConnectionString %>"
SelectCommand="SELECT JSA_Groups.[Group_ID], JSA_Groups.[Description] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID <> JSA_Groups_1.Parent WHERE (JSA_Groups.[Parent] = @Group_ID) ORDER BY JSA_Groups.[Description]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Group_ID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Panel>
<asp:Panel runat="server" ID="DropDown3Form" Visible="False">
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource4"
DataTextField="Description" DataValueField="Group_ID">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetAppsConnectionString %>"
SelectCommand="SELECT JSA_Groups.[Group_ID], JSA_Groups.[Description] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID <> JSA_Groups_1.Parent WHERE (JSA_Groups.[Parent] = @Group_ID) ORDER BY JSA_Groups.[Description]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList2" Name="Group_ID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Panel>
<asp:Panel runat="server" ID="DropDown4Form" Visible="False">
<asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource5"
DataTextField="Description" DataValueField="Group_ID">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetAppsConnectionString %>"
SelectCommand="SELECT JSA_Groups.[Group_ID], JSA_Groups.[Description] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID <> JSA_Groups_1.Parent WHERE (JSA_Groups.[Parent] = @Group_ID) ORDER BY JSA_Groups.[Description]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList3" Name="Group_ID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Panel>
<asp:Panel runat="server" ID="DropDown5Form" Visible="False">
<asp:DropDownList ID="DropDownList5" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource6"
DataTextField="Description" DataValueField="Group_ID">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetAppsConnectionString %>"
SelectCommand="SELECT JSA_Groups.[Group_ID], JSA_Groups.[Description] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID <> JSA_Groups_1.Parent WHERE (JSA_Groups.[Parent] = @Group_ID) ORDER BY JSA_Groups.[Description]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList4" Name="Group_ID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Panel>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource2" ForeColor="#333333"
GridLines="Both" PageSize="20">
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:TemplateField HeaderText="Description" SortExpression="File_Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("File_Description") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" Height="20px" NavigateUrl='<%# Bind("File_Name") %>'
Target="_new" Text='<%# Bind("File_Description") %>' Width="600px"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetAppsConnectionString %>"
SelectCommand="SELECT DISTINCT [File_Description], [File_Name] FROM [JSA_FileNames] WHERE ([Group_ID] = @Group_ID) ORDER BY [File_Description]" OnSelecting="SqlDataSource2_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Group_ID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
Code-behind:
Imports System.Data.SqlClient, system.data
Partial Class JSA
Inherits System.Web.UI.Page
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Dim test As Boolean = False
Try
Dim queryString As String = "SELECT JSA_Groups.[Group_ID], JSA_Groups.[Description] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID <> JSA_Groups_1.Parent WHERE (JSA_Groups.[Parent] = @Group_ID)"
Dim connection As New SqlClient.SqlConnection("Data Source=data")
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(queryString, connection)
command.Parameters.AddWithValue("@Group_ID", DropDownList1.SelectedValue)
Dim reader As SqlClient.SqlDataReader
command.Connection.Open()
reader = command.ExecuteReader
reader.Read()
If reader.HasRows Then
test = True
End If
command.Connection.Close()
Catch ex As SystemException
Response.Write(ex.ToString)
End Try
If test = True Then
DropDown2Form.Visible = True
DropDown3Form.Visible = False
DropDown4Form.Visible = False
DropDown5Form.Visible = False
Else
DropDown2Form.Visible = False
DropDown3Form.Visible = False
DropDown4Form.Visible = False
DropDown5Form.Visible = False
End If
End Sub
Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged
Dim test As Boolean = False
Try
Dim queryString As String = "SELECT JSA_Groups.[Group_ID], JSA_Groups.[Description] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID <> JSA_Groups_1.Parent WHERE (JSA_Groups.[Parent] = @Group_ID)"
Dim connection As New SqlClient.SqlConnection("Data Source=data")
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(queryString, connection)
command.Parameters.AddWithValue("@Group_ID", DropDownList2.SelectedValue)
Dim reader As SqlClient.SqlDataReader
command.Connection.Open()
reader = command.ExecuteReader
reader.Read()
If reader.HasRows Then
test = True
End If
command.Connection.Close()
Catch ex As SystemException
Response.Write(ex.ToString)
End Try
If test = True Then
DropDown3Form.Visible = True
DropDown4Form.Visible = False
DropDown5Form.Visible = False
Else
DropDown3Form.Visible = False
DropDown4Form.Visible = False
DropDown5Form.Visible = False
End If
End Sub
Protected Sub DropDownList3_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList3.SelectedIndexChanged
Dim test As Boolean = False
Try
Dim queryString As String = "SELECT JSA_Groups.[Group_ID], JSA_Groups.[Description] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID <> JSA_Groups_1.Parent WHERE (JSA_Groups.[Parent] = @Group_ID)"
Dim connection As New SqlClient.SqlConnection("Data Source=data")
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(queryString, connection)
command.Parameters.AddWithValue("@Group_ID", DropDownList3.SelectedValue)
Dim reader As SqlClient.SqlDataReader
command.Connection.Open()
reader = command.ExecuteReader
reader.Read()
If reader.HasRows Then
test = True
End If
command.Connection.Close()
Catch ex As SystemException
Response.Write(ex.ToString)
End Try
If test = True Then
DropDown4Form.Visible = True
DropDown5Form.Visible = False
Else
DropDown4Form.Visible = False
DropDown5Form.Visible = False
End If
End Sub
Protected Sub DropDownList4_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList4.SelectedIndexChanged
DropDown5Form.Visible = True
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
End If
End Sub
Protected Sub SqlDataSource2_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
If Not IsPostBack Then
If DropDownList2.SelectedValue = "" Then
e.Command.Parameters("@Group_ID").Value = DropDownList1.SelectedValue
Else
If DropDownList3.SelectedValue = "" Then
e.Command.Parameters("@Group_ID").Value = DropDownList2.SelectedValue
Else
If DropDownList4.SelectedValue = "" Then
e.Command.Parameters("@Group_ID").Value = DropDownList3.SelectedValue
Else
If DropDownList5.SelectedValue = "" Then
e.Command.Parameters("@Group_ID").Value = DropDownList4.SelectedValue
Else
e.Command.Parameters("@Group_ID").Value = DropDownList5.SelectedValue
End If
End If
End If
End If
End If
End Sub
End Class
|
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 05.09.2008 at 11:14PM PDT, ID: 21538018 |
| 05.10.2008 at 05:53AM PDT, ID: 21538860 |
| 05.14.2008 at 06:19AM PDT, ID: 21563799 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: |
<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="Description" DataValueField="Group_ID"
DataSource='<%# PopulateList() %>' AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
cod-behind:
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Dim test As Boolean = False
Try
'I did this just to determine if I should show the next dropdown or not... each dropdown is in its own form
Dim queryString As String = "SELECT JSA_Groups.[Group_ID], JSA_Groups.[Description] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID <> JSA_Groups_1.Parent WHERE (JSA_Groups.[Parent] = @Group_ID)"
Dim connection As New SqlClient.SqlConnection("Data Source=HCISSQL2;Initial Catalog=...;User ID=apps;Password=...")
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(queryString, connection)
command.Parameters.AddWithValue("@Group_ID", DropDownList1.SelectedValue)
Dim reader As SqlClient.SqlDataReader
command.Connection.Open()
reader = command.ExecuteReader
reader.Read()
If reader.HasRows Then
test = True
DropDownList2.DataBind()
End If
command.Connection.Close()
Catch ex As SystemException
Response.Write(ex.ToString)
End Try
If test = True Then
DropDown2Form.Visible = True
DropDown3Form.Visible = False
DropDown4Form.Visible = False
DropDown5Form.Visible = False
Else
DropDown2Form.Visible = False
DropDown3Form.Visible = False
DropDown4Form.Visible = False
DropDown5Form.Visible = False
End If
End Sub
Protected Function PopulateList() As DataTable
Dim queryString As String = "SELECT JSA_Groups.[Group_ID], JSA_Groups.[Description] FROM [JSA_Groups] INNER JOIN JSA_Groups JSA_Groups_1 ON JSA_Groups.Group_ID = JSA_Groups_1.Group_ID AND JSA_Groups.Group_ID <> JSA_Groups_1.Parent"
Dim connection As New SqlClient.SqlConnection("Data Source=HCISSQL2;Initial Catalog=...;User ID=apps;Password=...")
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(queryString, connection)
Dim dr As SqlDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
Dim _dtList As New DataTable()
_dtList.Load(dr)
_dtList.Columns.Add("Group_ID")
_dtList.Columns.Add("Description")
_dtList.Rows.Add(0, "-- Select a value --")
'Use for each loop and add it to the datatable
For Each row As DataRow In (_dtList.Rows)
DropDownList1.DataValueField = ("Group_ID")
DropDownList1.DataTextField = ("Description")
Next
DropDownList1.DataBind()
Return _dtList
End Function
I am currently getting this error: I set a breakpoint at the function populateList, and get this error before that happens....
Input string was not in a correct format.
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2755599
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +112
System.String.System.IConvertible.ToInt32(IFormatProvider provider) +43
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +217
System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType) +896
[FormatException: Failed to convert parameter value from a String to a Int32.]
System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType) +943
System.Data.SqlClient.SqlParameter.GetCoercedValue() +29
System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc) +97
System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser, SqlParameterCollection parameters) +166
System.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc) +253
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1005
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +122
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +50
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
|