Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I need a solution that

in my data base there are various question and I stored it in dataset , now when I will click on the button the question will show in a label one by one when click on button.

Is there any process then please help.



Thanks.
Posted

Yes there is a process. Its called databinding and is covered in every basic ASP.NET book I know of.
 
Share this answer
 
v2
Comments
Jimut123456789 15-May-12 8:14am    
please give the solution
[no name] 15-May-12 8:29am    
You have the solution. Read a book. This is very basic knowledge and you will not get very far without knowing how to find such basic information.
hi,
change the connectionstring and select Query as your requirement.
C#
public void FetchData_and_Show_in_Label()
   {
       String ConnStr = "Data Source=ServerName;Initial Catalog=DBNamae;User ID=UserName;Password='password';";
       String SQL = "SELECT QuestionText  FROM Questions";
       SqlDataAdapter Adpt = new SqlDataAdapter(SQL, ConnStr);
       DataSet question = new DataSet();
       Adpt.Fill(question);

       foreach (DataRow dr in question.Tables[0].Rows)
       {
           LblQuestion.Text += question.Tables[0].Rows[0]["QuestionText"].ToString() + "<br />";
       }
   }
 
Share this answer
 
v3
Comments
JBSAHU 15-May-12 8:22am    
my question is that by click on button it will show question one by one, May be button or Timer.
tanweer 15-May-12 8:28am    
I just updated the answer, please look again,
[no name] 15-May-12 8:30am    
Try reading about databinding and data bound controls, such as Repeater or DataList.
echo
PHP
"<form method='POST' action=''>";
if(!isset($a))
{
$_POST['a']=1
}
else
{
}
include('connection.php');
$s="SELECT * FROM questions LIMIT '$_POST['a'],1";
$res=mysql_query($s);
while($row = mysql_fetch_array($res))
{
echo $row['Question'];
}
$b=$_POST['a']+1;
echo "<input type='hidden' value='$b' name='a'>";
echo "<input type='submit' value='submit' name='submit'>";
?>
 
Share this answer
 
v2
Correct me if I'm wrong.. After button click, You'd like to display all your questions from dataset and display it one by one after a certain period of time?

If that is the case then you'll need a timer.
 
Share this answer
 
Comments
CHill60 10-Dec-13 7:23am    
I'm correcting you ... OP said "question will show in a label one by one when click on button." They also said it a year and a half ago

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900