|
Sry for Dat i will remember in future,
sectorTable
sectorId
sectorName
date
subSector Table
SubSectorId
sectorId
subsectorName
date
output should like dis in dropdownlist box
sectorName(a)
subsectorName(a)
subsectorName(a)
sectorName(b)
subsectorName(b)
subsectorName(b)
a & b are sectorId
regards,
Rahul
rahul saini
|
|
|
|
|
Query:
select sectorTable.sectorId Sectorid, sectorName, SubSectorId, subsectorName<br />
from sectorTable, subSectorTable<br />
where sectorTable.sectorId = subSectorTable.sectorId<br />
order by sectorTable.sectorId
Change as per table names and syntax as per database type.
Code for filling drop down:
dim prevsecid as integer = 0<br />
<br />
dr.read (where dr is the datareader object)<br />
prevsecid = dr("Sectorid")<br />
add sector info to drop down (text = sector name, value = sector id)<br />
add sub sector info to drop down (text = sub sector name, value = sub sector id)<br />
<br />
while dr.read<br />
<br />
if prevsecid = dr("Sectorid")<br />
<br />
add sub sector info to drop down<br />
<br />
else<br />
<br />
prevsecid = dr("Sectorid")<br />
add sector info to drop down<br />
add sub sector info to drop down<br />
<br />
end if<br />
<br />
Loop
You can put the foll code in a function for easy reuse
add sector info to drop down
add sub sector info to drop down
If you want the indentation as shown in your post above, add something like "-->" to the subsector name when adding it to dropdown.
Hope this helps.
Shreekar
http://shreekarishere.blogspot.com
|
|
|
|
|
hi,
thanks for dis sollution.
but code to fill dropdown is not working. can u please explain little bit more.
thnkx.
regards
rahul
rahul saini
|
|
|
|
|
Please be more specific as to what is not working.
Post some code that you are using / giving errors.
Shreekar
http://shreekarishere.blogspot.com
|
|
|
|
|
Sub fillSectorDropdown()
Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
Dim MyConnection As SqlConnection
MyConnection = New SqlConnection(Application("dbStrConn").ToString())
Dim sql As String = "select SectorId,SectorName,subSectorId,subSectorName from(Sector, subSector) where(SectorId = subSectorId) order by Sector.SectorId"
MyCommand = New SqlDataAdapter(sql, MyConnection)
Dim prevsecid As Integer = 0
Dim objDR As SqlDataReader
If objDr.Read Then
'While (objDr.Read) 'dis is not working
If prevsecid = objDr("jobSectorCategoryId") Then
chooseSector.DataSource = DS
chooseSector.DataSource = DS.Tables(0)
chooseSector.DataTextField = DS.Tables(0).Columns("Sector").ColumnName.ToString()
Sector.DataValueField = DS.Tables(0).Columns("SectorId").ColumnName.ToString()
chooseSector.DataBind()
'add sub sector info to drop down
Else
prevsecid = objDr("subSectorId")
'add sector info to drop down
'add sub sector info to drop down
chooseSector.DataSource = DS
chooseSector.DataSource = DS.Tables(0)
chooseSector.DataTextField = DS.Tables(0).Columns("Sector").ColumnName.ToString()
chooseSector.DataValueField = DS.Tables(0).Columns("SectorId").ColumnName.ToString()
chooseSector.DataBind()
End If
'Loop
End If
End Sub
i m using dis code please retify dis code
thanx
regards.
rahul
rahul saini
|
|
|
|
|
Sir,
Can i programically delete the history in vb.net.
Thanks
|
|
|
|
|
Hi Friend ,This code may helpful to u
Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1D)
Response.Expires = -1500
Response.CacheControl = "no-cache"
|
|
|
|
|
Sir,
Thanks for ur kind attention.
One more question.
what is the meaning of (-1D) in
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1D)
Thanks
|
|
|
|
|
Hello,open this link to understand the code i send to u
http://www.codeproject.com/useritems/NoCaching.asp
|
|
|
|
|
hi,
How To Programmatically Create a DSN for SQL Server in C# ASP.NET.
kamalnath
|
|
|
|
|
|
Hi,
I am using DataReader to read data from database and comparing the values with textbox values entered(something like in login page to chk whether the user exists)but even the values are same it displays user not valid.
what r the options for comparing values?
herez my code
if((dr.GetValue(0).ToString().Equals(txtUserName.Text.ToString()))&&(dr.GetValue(1).ToString().Equals(txtPassword.Text.ToString())))
{
Response.write("User is valid");
}
else
{
Response.write("User is not valid");
}
Thanks,
Mini
|
|
|
|
|
You can use the string.Compare method to specify if the comparison should be case sensetive or not. Usually the comparison for user name is not case sensetive, but the password is.
---
b { font-weight: normal; }
|
|
|
|
|
Well one another way is that u must compare by applying == among two string like...
dr.GetValue(0)==txtUserName.Text
may be this will helpfull..
KHATRI
|
|
|
|
|
Well you can also compare the two values by applying == to them
Like
dr.GetValue(0)==txtUserName.Text
similarly u can do more..
May be this is helpfull to u
Khatri
|
|
|
|
|
I would suggest that you relegate this task to the database by changing your query and adding filter for username and password (if applicable)
As for comparison, you can make both values upper case/lower case and then compare (if they are strings) or use object comparison (for objects).
Shreekar
http://shreekarishere.blogspot.com
|
|
|
|
|
Try the following code
if((dr.GetValue(0).ToString()==txtUserName.Text.ToString())&&(dr.GetValue(1).ToString()==txtPassword.Text.ToString()))
{
Response.write("User is valid");
}
else
{
Response.write("User is not valid");
}
Thanks and Regards,
Suresh Dayma
Everything Is Possible!
|
|
|
|
|
Thanks to all..
All ur replies r working fine...
Thanks,
Mini
|
|
|
|
|
How can we check whether a certain culture is supported by the framework or not. I have 2 strings as "en-US" and "MyName". It should set the culture if I pass "en-US" and should take the default culture of the browser if i pass "MyName". Can anyone suggest.
|
|
|
|
|
You could use the CultureInfo object in the Globalization namespace. This has a contructor that takes the "en-US". Try that and in the catch you could do a Request.UserLanguages.GetValue(0)
|
|
|
|
|
guys i would like to ask how to create buttons during run time if its possible that is.
|
|
|
|
|
Dim loButton as Button = New Button
loButton.Text = "Some Text"
loButton.Visable = True
form1.Controls.Add(loButton)
You should try looking at MSDN first. You will most likly get most of these answers from there without having to wait.
|
|
|
|
|
Well i want to add few more things in the code that TadMcClellan has provided.
Provide the type of button that you want to create that is either HTML control input button or WebControl
Dim System.Web.UI.WebControl.Button as btn=new System.Web.UI.WebControl.Button()----This is for WebControl buttons..
similarly u can provide anytype of button..
May be i m helpful to u..
KHATRI
|
|
|
|
|
hi guys i am in need of syntex for asp 1.1:
connecting to an ms sql database during runtime.
i would also like to ask if it is possible to connect to the database server at the same place.
meaning if it is possible to connect to the database server and the database in the script while in run time.
|
|
|
|
|
Um.. Yes. Actualy this is how you should do it, using some common object to open the connections and commands for you and returning the datatables you need.
If you use C# be sure to use the "Using" Syntext. In 1.1 VB.Net you can't do this so be sure to close the connection after your done with it.
If you need help with Conection Strings go Here[^].
Do an MSDN Search on SQLConnection and that will give you the syntext you need.
|
|
|
|