Click here to Skip to main content
15,901,001 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: To avoid post back? Pin
Parwej Ahamad1-Jul-08 17:44
professionalParwej Ahamad1-Jul-08 17:44 
GeneralRe: To avoid post back? Pin
BalasubramanianK1-Jul-08 18:00
BalasubramanianK1-Jul-08 18:00 
GeneralRe: To avoid post back? Pin
BalasubramanianK1-Jul-08 18:13
BalasubramanianK1-Jul-08 18:13 
AnswerRe: To avoid post back? Pin
niraj_kush7-Jul-08 21:59
niraj_kush7-Jul-08 21:59 
Questionhow to display data visually from database inside html table Pin
Rameez Raja1-Jul-08 17:19
Rameez Raja1-Jul-08 17:19 
AnswerRe: how to display data visually from database inside html table Pin
Gayani Devapriya1-Jul-08 17:56
Gayani Devapriya1-Jul-08 17:56 
GeneralRe: how to display data visually from database inside html table Pin
Rameez Raja1-Jul-08 23:09
Rameez Raja1-Jul-08 23:09 
GeneralRe: how to display data visually from database inside html table Pin
Gayani Devapriya3-Jul-08 2:22
Gayani Devapriya3-Jul-08 2:22 
Hi,

My email is gayani.devapriya@gmail.com, but Im sorry to say that I cannot access private mails account from my office. So Ill just stick to the Code Project Forum for the time being.

I justed looked at the sample link given. First of all I need to know for whot sort of a object you get the data from the database. ie; innitialy are you getting it to a Dataset or a Collection?

I will show a simple example using a Dataset.
DataSet dsSchedule = GetMySchedule();
This wil have a structure like
Channel, Time, Program
C1 T1 P1
C2 T2 P2
C1 T3 P3
Now you want it to look like
Channel T1 T2 T3
C1 P1 NA P3
C2 NA P2 NA

1. Create a Panel where you want this table to be.
2. Now we will create a table dynamically.
Table tblDetails = new Table();
2.1. Create Table headers.
TableRow trHeader = new TableRow();
2.1 Now lets add cell by cell.
Create the first cell to represnt the Channel.
TableHeaderCell thcChannel = new TableHeaderCell();
thcChannel.Text = "Channel";
trHeader.Cells.Add(thcChannel);

Now for the other header cells, write a method to get all the Times(T).
Lets say you get all the times(T1,T2) to a List. List<string> times = new List<string>();
times = //Write a method to retrive all times.
traverse the list now using for each and assign each time(T) to the cell's Text property, and add the cell to the row, as explained above.
And add the header to the table
tblDetails.Rows.Add(trHeader);
By now your table header will be complete.

2.2. Lets create rows now.
First cell of the row should have the channel name(ex : C1, C1), while others with the program names(ex : P1, P2)
The initial dataset dsSchedule will have all these data.
foreach(DataRow dr in dsSchedule.Table[0].Rows)
{
TableRow trData = new TableRow();

TableCell tcChannel = new TableCell();
tcChannel.Text = dr["Channel"].ToString();
trData .Cells.Add(tcChannel);

Now for each channel and time we need to get the value, so you may filter your dataset as follows.
foreach(string sTime in times)
{
string sCurrentChannel = dr["Channel"].ToString();
string sCurrentTime = sTime;
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = "Channel == '" + sCurrentChannel + "' & Time == '" + sCurrentTime + "'";
DataTable dt = dv.ToTable();

string sProgram = string.Empty;
if (dt == null)
{
sProgram = "NA";
}
else
{
sProgram = dt.Rows[2].ToString();
}
TableCell tcProgram = new TableCell();
tcProgram .Text = sProgram;
trData.Cells.Add(tcProgram );


}

tblDetails.Rows.Add(trData);
}
Now all your data should be there.
3. Add the table to the Panel
pnlSchedule.Controls.Add(tblDetails);

Hope its clear..
Thx,
Gayani
GeneralRe: how to display data visually from database inside html table Pin
Rameez Raja4-Jul-08 17:03
Rameez Raja4-Jul-08 17:03 
GeneralRe: how to display data visually from database inside html table Pin
Gayani Devapriya5-Jul-08 8:26
Gayani Devapriya5-Jul-08 8:26 
GeneralRe: how to display data visually from database inside html table Pin
Rameez Raja5-Jul-08 17:29
Rameez Raja5-Jul-08 17:29 
QuestionCertification Exam 70-528 Question Pin
AlexeiXX31-Jul-08 10:07
AlexeiXX31-Jul-08 10:07 
GeneralProblem running with ASP.NET 2.0 applications Pin
Saikiranpuppala1-Jul-08 7:06
Saikiranpuppala1-Jul-08 7:06 
QuestionScript Manager : Access is Denied Pin
ctrlnick1-Jul-08 5:59
ctrlnick1-Jul-08 5:59 
AnswerRe: Script Manager : Access is Denied Pin
Parwej Ahamad1-Jul-08 6:24
professionalParwej Ahamad1-Jul-08 6:24 
AnswerRe: Script Manager : Access is Denied Pin
ToddHileHoffer1-Jul-08 7:30
ToddHileHoffer1-Jul-08 7:30 
Questionhtml Image as button needs two clicks after the page loaded Pin
gottimukkala1-Jul-08 5:42
gottimukkala1-Jul-08 5:42 
QuestionRe: html Image as button needs two clicks after the page loaded Pin
Abhijit Jana1-Jul-08 5:59
professionalAbhijit Jana1-Jul-08 5:59 
AnswerRe: html Image as button needs two clicks after the page loaded Pin
gottimukkala1-Jul-08 6:16
gottimukkala1-Jul-08 6:16 
GeneralRe: html Image as button needs two clicks after the page loaded Pin
Abhijit Jana1-Jul-08 6:19
professionalAbhijit Jana1-Jul-08 6:19 
GeneralRe: html Image as button needs two clicks after the page loaded Pin
gottimukkala1-Jul-08 6:27
gottimukkala1-Jul-08 6:27 
GeneralRe: html Image as button needs two clicks after the page loaded Pin
Abhijit Jana1-Jul-08 7:15
professionalAbhijit Jana1-Jul-08 7:15 
GeneralRe: html Image as button needs two clicks after the page loaded Pin
gottimukkala1-Jul-08 7:25
gottimukkala1-Jul-08 7:25 
GeneralRe: html Image as button needs two clicks after the page loaded Pin
Abhijit Jana1-Jul-08 7:34
professionalAbhijit Jana1-Jul-08 7:34 
GeneralRe: html Image as button needs two clicks after the page loaded Pin
gottimukkala1-Jul-08 11:09
gottimukkala1-Jul-08 11:09 

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.