|
Can someone please help me with the bolded parts of the code below? I'd like to add another querystring value to BusinessInfo.aspx. I'd like for it to be something like BusinessInfo.aspx?ID=2&CatID=4. I already have the ID set up. But I'd like to be able to retrieve the CatID (see the code for the data list) and put it as a value for the second query string. The CatID comes from a query string on the previous web page. I have an idea of how to do this in Classic ASP, but I'm not sure how you would do this with a data list in ASP.Net.
<form runat="server"> <asp:datalist ID="dtlCity" runat="server" Width=500 RepeatColumns=4 enableviewcounty=false> <itemtemplate> <table cellpadding=2> &nbs p; <!--DWLayoutTable--> &nbs p; <tr> &nbs p; <td height="6"></td> &nbs p; <td width="1"></td> &nbs p; </tr> &nbs p; <tr valign="top"> &nbs p; <td> <a href='<%# DataBinder.Eval (Container.DataItem, "CityID", "BusinessInfo.aspx?ID={0}") %>'> &nbs p; <font color="#660099" size="2" face="Arial, Helvetica, sans-serif"> &nbs p; <%# DataBinder.Eval (Container.DataItem, "City") %> &nbs p; </font> </a> </td> &nbs p; <td></td> &nbs p; </tr> </table> </itemtemplate> </asp:datalist> </form></td>
Code for DataList:
Sub BindCityList()
Dim strConnect As String Dim Conn As New System.Data.SqlClient.SQLConnection Dim objCommand As New System.Data.SqlClient.SQLCommand Dim strSQL as String Dim dtaCity As New System.Data.SqlClient.SQLDataAdapter() Dim dtsCity As New DataSet() Dim strSubCategory As String 'Get connection string from Web.Config strConnect = ConfigurationSettings.AppSettings("ConnectionString")
Conn = New System.Data.SqlClient.SQLConnection(strConnect) Conn.Open() 'Get incoming querystring values strSubCategory = request.params("CatID")
'Start SQL statement strSQL = "select * from City Order By City asc"
'Set the Command Object properties objCommand.Connection = Conn objCommand.CommandType = CommandType.Text objCommand.CommandText = strSQL
'Create a new DataAdapter object dtaCity.SelectCommand = objCommand
'Get the data from the database and 'put it into a DataTable object named dttCity in the DataSet object dtaCity.Fill(dtsCity, "dttCity")
'Set the DataSource property of the DataGrid dtlCity.DataSource = dtsCity
'Bind all the controls on the page dtlCity.DataBind() objCommand.ExecuteNonQuery() 'this is the way to close commands objCommand.Connection.Close() Conn.Close()
End Sub
I tried doing the following: <a href='<%# String.Format("Businessinfo.aspx?id={0}&catId={1}",DataBinder.Eval (Container.DataItem, "CityID"), request.params("CatID")) %>'> , but it doesn't show up on the web page at all. There's no error message. The links just don't show up anymore.
|