I am trying to create a page where a list of doctors will appear from my database. But without using the Gridview. I want to display the informations as in the image below. Please help me.image
If you use vb.net...you must use repeater. Other way is iterate data with a for.
Doc for repeater:
https://learn.microsoft.com/en-us/aspnet/web-forms/overview/data-access/displaying-data-with-the-datalist-and-repeater/displaying-data-with-the-datalist-and-repeater-controls-vb
Doc for iterate lists:
https://learn.microsoft.com/es-es/dotnet/visual-basic/language-reference/statements/for-each-next-statement
Related
Hello I'm developing a asp. Net page where I want to populate many tables in the ui
But I want it to be dynamic.
Eg: If I retrieve only 2 rows as per search criteria then I want to display only 2 tables.
I tried dynamic table creation using string builder but I got a null reference because the table Id was not being read . Is there any other way where I can create tables dynamically in the html page or should I do it in the code behind itself , then get the Id using flow control and then populate the table. Please help!!!
The problem of creatig tables dynamically has been rectified but now i cannot retrive their ids so that i can print values retrived from the datatbase in it using id.text command.
this is my code
StringBuilder htmlTable = new StringBuilder();
htmlTable.AppendLine("<table>");
htmlTable.AppendLine("<tr>");
htmlTable.AppendLine("<th>colum1</th>");
htmlTable.AppendLine("<th>colum2</th>");
htmlTable.AppendLine("<th>colum3</th>");
htmlTable.AppendLine("</tr>");
htmlTable.AppendLine("<tr>");
htmlTable.AppendLine("<td><asp:Label runat='server' id='lblt0'></asp:Label></td>");
htmlTable.AppendLine("<td>colum2data</td>");
htmlTable.AppendLine("<td>colum3data</td>");
htmlTable.AppendLine("</tr>");
htmlTable.AppendLine("</table>");
litTable.Text = htmlTable.ToString();
//litTable is the id of my asp:literal tag
You cannot create a table with a runat=server tag in this manner. Adding items to a literal control can only create client side markup not server side controls.
Your best route is to use a GridView as suggested or an HtmlTable
GridView: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview(v=vs.110).aspx
HtmlTable: http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable(v=vs.110).aspx
If your example really is as trivial as the one you provided an HtmlTable might be the easiest route. Though if you want to populate your table from a database or some other data source a GridView is your best option.
This might be a silly question. But I have a lot of textboxes in an in asp.net form I need to populate with data from a sql query.
If the query column names and textbox names are all the same, is it possible to populate the textboxes from the query data automatically? Maybe using loop? There are too many fields so I think it is stupid to populate each field individually using something like:
textboxX.text = data.getValue(0).ToString();
textboxY.text = data.getValue(1).ToString();
...
I am thinking there must be a simpler way to populate all of the textboxes. Can anyone please help me to do this? A simple example would be great.
If you were using something like MVC or MVVM then it would be in a manner of speaking. You could tie your view page to a model that has properties corresponding to the fields. Then in your view page you would bind the model properties to the fields.
If you don't work with MVC/MVVM/knockout then the best thing you could do is to loop your form's controls and assign them some values from your list. For this purpose it's simplier if your controls are named like Ctrl1, Ctrl2, etc - it's just to simplify the looping/assignment
I've got a Repeater displaying a list of Countries, and nested within this is another Repeater displaying categories, and nested within this is another Repeater displaying news articles.
This is working fine, however users should be able to enter a keyword and filter the search.
What is the best way of filtering this? Am I going to have to pass identical parameters to 3 different SQL Commands? I'd rather not..
Also, how can I then page this correctly so there are still x amount of articles per page?
Any help much appreciated.
If you store resultset from your DB in a DataTable, and then bind that table to the repeater you can filter the table by using DataTable.Select() method.
I have a tbl_categories and a tbl_items. I want to display tbl_categories in a horizontal manner and list objects from tbl_items vertically below each category name. I am confused how to get all this data using TSQL stored procedures and displaying them using ASP.NET native controls.
Columns with headers of category names. rows of items keyed with category_id.
The db is set up correctly. It is the ASP.NET controls I have trouble with.
I would use a Repeater myself, and make it output an HTML Table. The categories row would be in the HeaderTemplate, the closing tags in the FooterTemplate, and the actual data inside the ItemTemplate
http://blogs.sitepoint.com/asp-net-repeater-control/
The best way to handle this is to setup business objects which support the data in a way you wish to present it, which may not always be the way it is handled by your database.
Then you can use those objects directly to bind or feed data into the UI.
You could use Pivot to do that. See this referece http://msdn.microsoft.com/en-us/library/ms177410.aspx
Can a GridView be bound to a List<>?
I want to create a Master Details scenario. So The first List<> contains Master data and the second Child data. When the user clicks on the Master Data, the child data, should appear in a pop.
Is that possible? Please share some code.
Yes, this is possible. Take a look at the ObjectDataSource to use for databinding a list to a GridView. It requires some more manual coding, but it works.
There's a good discussion of one possible solution here that manually constructs a DataTable from your business object list to make filtering/sorting/paging easier than manually implementing those methods.
You can create on temporary table and then bind that table with grid.
Like,
dataset.DataSource=tempTable;
tempTable.DataBind();
GridView1.DataSource = theList;<br/>
GridView1.DataBind();