Click here to Skip to main content
15,894,460 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Help Me Pin
hamed200929-Jun-09 21:38
hamed200929-Jun-09 21:38 
AnswerRe: Help Me Pin
Christian Graus30-Jun-09 0:16
protectorChristian Graus30-Jun-09 0:16 
GeneralRe: Help Me Pin
dan!sh 30-Jun-09 0:21
professional dan!sh 30-Jun-09 0:21 
GeneralRe: Help Me Pin
Christian Graus30-Jun-09 10:34
protectorChristian Graus30-Jun-09 10:34 
QuestionImage reference Pin
jhp53129-Jun-09 17:22
jhp53129-Jun-09 17:22 
AnswerRe: Image reference Pin
jhp53130-Jun-09 0:17
jhp53130-Jun-09 0:17 
QuestionDropdown box display issue in vb .net Pin
Member 451421829-Jun-09 17:04
Member 451421829-Jun-09 17:04 
AnswerRe: Dropdown box display issue in vb .net Pin
Henry Minute30-Jun-09 2:50
Henry Minute30-Jun-09 2:50 
I think the solution to your problem is quite simple, but I cannot be sure because your code snippet is so badly formatted that it is difficult to read.

Next time you post some code please use the 'code block' widget (below the Text: box). Put the cursor on a new line, click the 'code block' and then paste your code between the opening and closing tags. That way all of your formatting etc. will be retained, making it easier for people to read and therefore more likely that you will get a response.

OK, lecture over. To solve your problem, whilst using your existing code, modify your RadioButton2_CheckedChanged method like this:
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
  TStudentId.Visible = True
  StudentId.Visible = False
  Button1.Visible = False
  Button2.Visible = True
  Button3.Visible = True

  Dim i As Integer
  Dim da As New SqlDataAdapter
  Dim ds As New DataSet
  Dim dt As New DataTable

  TStudentId.Items.Clear()  '<========================= HERE'S the change, get rid of the old stuff before adding the new
  Conn.Open()
  Cmd = Conn.CreateCommand
  Cmd.CommandText = "Select StudentId from Student"
  da.SelectCommand = Cmd
  da.Fill(ds, "Student")
  dt = ds.Tables("Student")
  For i = 0 To dt.Rows.Count - 1
    TStudentId.Items.Add(dt.Rows(i).Item(0))
  Next

  Fname.Text = ""
  Lname.Text = ""
  Address.Text = ""
  Mobile.Text = ""
  EmailId.Text = ""
  Conn.Close()
End Sub


But I have to ask. Why not just set TStudentId.DataSource to dt, rather than use the For..Next loop as you do?

Another lecture coming up, sorry! Smile | :)
For your own peace of mind, do try to stop using silly member names (da for a DataAdapter, dt for a DataTable), sure you remember what they do now, but in six months you won't. And what are you going to do when you need more than one DataAdapter, use da2? Instead of dt, how about StudentIdTable, or tblStudentID, and so on.
Also RadioButton2, what does it do? Again you know now, but in six months?? And more importantly in this case It took me a lot more reading to work out what was going on than it should have done. Give all members and controls (with the possible exception of Labels) sensible descriptive names. How about rbtnShowId for example 'rbtn' tells me it is a RadioButton 'ShowId' tells me that it shows/hides the Id Dropdown, devise your own naming scheme and stick to it.

It will make your life so much easier in future.

Rant over. Sorry again. Smile | :)

Anyway, good luck!

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

QuestionDeveloping on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
Daniel Boling29-Jun-09 11:26
Daniel Boling29-Jun-09 11:26 
AnswerRe: Developing on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
Christian Graus29-Jun-09 13:21
protectorChristian Graus29-Jun-09 13:21 
AnswerRe: Developing on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
EliottA29-Jun-09 13:53
EliottA29-Jun-09 13:53 
GeneralRe: Developing on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
Daniel Boling30-Jun-09 2:41
Daniel Boling30-Jun-09 2:41 
GeneralRe: Developing on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
EliottA30-Jun-09 2:48
EliottA30-Jun-09 2:48 
QuestionMS VB 2008 express, install for all users Pin
Jesper hoegh29-Jun-09 9:12
Jesper hoegh29-Jun-09 9:12 
AnswerRe: MS VB 2008 express, install for all users Pin
Dave Kreskowiak29-Jun-09 9:45
mveDave Kreskowiak29-Jun-09 9:45 
Questionmake limit time to the vedio capture Pin
my30name29-Jun-09 5:31
my30name29-Jun-09 5:31 
AnswerRe: make limit time to the vedio capture Pin
garfield18529-Jun-09 5:34
garfield18529-Jun-09 5:34 
GeneralRe: make limit time to the vedio capture [modified] Pin
my30name29-Jun-09 22:56
my30name29-Jun-09 22:56 
QuestionString$ function Pin
garfield18529-Jun-09 5:12
garfield18529-Jun-09 5:12 
AnswerRe: String$ function Pin
Nagy Vilmos29-Jun-09 5:35
professionalNagy Vilmos29-Jun-09 5:35 
AnswerRe: String$ function Pin
Luc Pattyn29-Jun-09 5:35
sitebuilderLuc Pattyn29-Jun-09 5:35 
GeneralRe: String$ function Pin
garfield18529-Jun-09 5:46
garfield18529-Jun-09 5:46 
GeneralRe: String$ function Pin
Luc Pattyn29-Jun-09 7:00
sitebuilderLuc Pattyn29-Jun-09 7:00 
Questioncrystal report problem in after installation ? Pin
JC.KaNNaN29-Jun-09 4:44
JC.KaNNaN29-Jun-09 4:44 
AnswerRe: crystal report problem in after installation ? Pin
EliottA29-Jun-09 5:08
EliottA29-Jun-09 5:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.