Get Field Dynamically

Posted by Riyazhaider under Sql Server on 3/26/2015 | Points: 10 | Views : 341 | Status : [Member] | Replies : 2
I have a web application in which i display some alert or information based on database. to display a new parameter or
some new fields i have to modify source code and then deploy the application. is there any way by which i can dynamically add parameters thorough admin module or any other method so that i should be able to display new fields on the fly.
Need urgent solution.




Responses

Posted by: Sheonarayan on: 3/26/2015 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hi Riyaz,

The approach should be to get all columns to display from the database to UI layer and display to the UI based on what user has selected or what you have set to display (you can store your selected column somewhere in the text file or any other file).

I have a similar example written in this article http://www.dotnetfunda.com/articles/show/1400/how-to-generate-gridview-columns-dynamically-based-on-user-selection.

Have a look at above article, that must help.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Riyazhaider, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajnilari2015 on: 3/31/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
Yes possible. Build the web page at runtime and build the tables where you want to display the data at runtime. So depending on what you want to display, it must be. Below is a pseudo code

e.g. 1.aspx
<div id="myDiv" runat="server" />


1.aspx.cs

Page_Load()

{
var x = "";
string str = "<html><head></head><body><table border='1'><tr><td>Name</td><td>Age</td></tr>";
for(int i=0;i<10;i++)
x =+ "<td>" + string.Concat("Name",i) + "</td><td>" + string.Concat("Age",i) + "</td>";

str+= x;
str += "</table></body></html>";

//finally add it to the div tag
myDiv.Controlls.Add(str);
}



Also you may follow the below links for more clarity

http://www.codeproject.com/Articles/25573/Building-ASP-NET-Web-Pages-Dynamically-in-the-Code

http://www.aspdotnet-suresh.com/2014/08/create-aspx-page-dynamically-in-asp-net-using-csharp-vbnet.html

http://www.dotnetspider.com/resources/26301-How-create-ASPX-Page-Dynamically-A-Step.aspx

https://msdn.microsoft.com/en-us/library/kyt0fzt1%28v=vs.140%29.aspx

http://visualstudiomagazine.com/articles/2010/10/07/dynamically-add-controls-at-runtime.aspx

http://www.aspsnippets.com/Articles/Create-dynamic-ASPX-page-in-ASPNet.aspx

--
Thanks & Regards,
RNA Team

Riyazhaider, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response