.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

dynamically add record in page

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :ASP.Net

I am creating page dynamically using this. I want to read the file, which is dynamically created and show content on page from database like 40 record in each page.

String root = Server.MapPath("~");
        String pgTemplate = root + "\\myPageTemplate.tmp";
        StringBuilder line = new StringBuilder();        
        using (StreamReader rwOpenTemplate = new StreamReader(pgTemplate))
            while (!rwOpenTemplate.EndOfStream)

        int ID = 0;
        string SaveFilePath = "";
        string SaveFileName = "";
        Random ran = new Ran

View Complete Post

More Related Resource Links

Creating asp.net page dynamically

Hi All:  I have a requirement that I need to create asp.net page dynamically for each folder inside a specific folder. I know the code to traverse each folder but I don't know how to create a new page dynamically and show the contents. Please help me on this.   Regards,  Asif HameedHi All: I have a requirement that I need to create asp.net page dynamically for each folder inside a specific folder. I know the code to traverse each folder but I don't know how to create a new page dynamically and show the contents. Please help me on this.  Regards, Asif Hameed

I need help with the syntax for passing a record field value from SSRS to an asp page

I have tried several variations without success.  Here is where I am now.  The goal is from inside Report Manager report, link to an asp page with a filed value. This is from the expression line of the Jump to URL entry. Also I am trying to open a new page http://www.whereever.com/CSSurvey01.asp?RecordID=" & Fields!respid.Value            

Dynamically change the page footer height

Hi, I want to dynamically change the page footer height based on a condition? Is that possible?   Thanks in Advance  

How to add a new button to the newform.aspx page which says "Save and add another record" ?

Team, I have a scenario where my client wants me to add a nother button to NewForm.aspx page in addition to Save and Cancel buttons. The job of that buttom should be to save the record and open that new form again. Is this possible.If yes can you guie me how to do it though designer? Thanks in advance. Deepti.  

Urgent- How to show sequential workflow on asp.net web page dynamically

Hi All,My basic question is how can we show a sequential workflow diagram on asp.net web page dynamically. using WWF can we do this?. i have gone throgh the some of forums/articles but i could not find right information anywhere. please suggest me the right path to achieve this.

Rearrange dynamically visible controls on a page

Hello,Here is what I am trying to do.I have a drop down list along with a 'Add' button (which are always visible). There are some other 'Label', 'TextBox', 'Button' in the page (which is not visible on load). Depending on the user selection from the first dropdown (and when click on 'Add' button), I would like to dynamically set some of the Controls visible.For example (as per below code): When User selects 'Email' ... Label3, TextBox3 and Button3 will be visible. Again when user will click Button3, all controls will be invisible. I was able to Show and Hide those controls as per user selection and button click. What I would like to do is, rearrange the controls. For example, If user selects 'Email' and click 'Add' button (Button5), It would display 'Label3', 'TextBox3', 'Button3'. Then if user selects 'Name' from the dropdown and click 'Add' button again, it would display 'Label1', 'TextBox1', 'Button1' below the Email controls. As of now it is apperaing on sequence as listed in html (Name controls always come first when visible, then 'Phone', then 'Email'). I would like to display the controls as sequesnce as user selects.And next is when we will click the Button3 (which will hide the email controls), All other controls below email co

How to set the heading of aspx page dynamically?

Hi,I would like to set the page heading according to the querystring value.So, it is something like this:From Page1.aspx I am redirecting to Page2.aspx.In Page1, I have list of image buttons depicting different Departments coming from database.On clicking the particular Image button I will be redirected to Page2.aspx which shows info regarding to that department.Page1.aspx code:<asp:ImageButton ID="imgbtnProject" runat="server" PostBackUrl='<%#GetUrl(DataBinder.Eval(Container.DataItem,"DeptId")) %>' ImageUrl='<%#String.Format("{0}{1}","images/Depts/",Eval("ImagePath"))%>'/>Page1.aspx.cs, GetUrl() method:protected string GetUrl(object ProjectId) { return string.Format("~/Page2.aspx?DeptId={0}", DeptId); }Now, I want to reset the page heading of Page2.aspx,depending on the Department,so, it should be:MyProject-Accounts,MyProject-Marketing etc.It is having master pages as well.Please suggest me how to do that.

Checking existence of a record in sql database using IF EXIST and reporting outcome on asp page



I have a page that inserts a record to an sql database and I would like to do the following:

(i) Check if a record already exist before trying do an insert

(ii) If a record exist, the page should be able to inform/display a message in a textbox informing the user that the record already exist.


I have seen a number of post on the internet that suggest that one possible solution is to write a sproc and use the T-sql IF EXIST function. However, I have NOT seen a complete code showing (a) how this can be done (b) how to call the sproc from an asp page (c) and MORE IMPORTANTLY how to display a message informing a user that a record already exist i.e. when the record already exist in the database.


Please have anyone got a complete working code that can achieve this preferably in c#?




Dynamically added text boxes disappears after page refresh


Dim objDatabase As New database
        Dim objAdapter As SqlDataAdapter
        Dim objDataset As New DataSet
        Dim objAdapter1 As SqlDataAdapter
        Dim objDataset1 As New DataSet
        Dim objAdapter2 As SqlDataAdapter
        Dim objDataset2 As New DataSet

        objAdapter = New SqlDataAdapter("SELECT first_name + ' ' + last_name as [Name],father_mobile_no as [Father Mob No],mother_mobile_no as [Mother Mob No] FROM student_data WHERE class='" & cmb_class.SelectedValue & "' and division = '" & cmb_division.SelectedValue & "' and school_id='" & Session("school_id") & "'", objDatabase.con)
        objAdapter.Fill(objDataset, 0)
        If objDataset.Tables(0).Rows.Count > 0 Then

            Dim dt_table As DataTable

How to create a Table of content in .rdl design in BIDS dynamically according to the Page no wise..?



well i am able to create the TOC statically by using the Document Map properties as describe in my older post issue 

but now i just want to create the Table of contents dynamically generate using the page no wise..is it possible...how can we do it while designing the .rdl in BIDS..



Using HttpModule to change master page dynamically on SharePoint 2010 site


I am trying to change master page dynamically on SharePoint 2010 site. I reviewed some documents (SharePoint: Dynamically Change Master Page: http://ranaictiu-technicalblog.blogspot.com/2009/10/sharepoint-dynamically-change-master.html) and I implemented IHttpModule, added it to GAC, modified web.config(safecontrol, httpmodule, module)
It works good! But I found some problems
1.Never catch the PreInit event for publishing pages
2."/_Layouts/RedirectPage.aspx" page occurred error
3.ContextMenu did not work

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using Microsoft.SharePoint;
using System.Configuration;
using Microsoft.SharePoint.ApplicationRuntime;

namespace MasterUtilModule
    public class MasterModule : IHttpModule
        public void Dispose() { }
        public void Init(HttpApplication context){

How to refresh page and dropdown after insert record from popup page


I have a page that is opened in a popup window from the main page. Once i click insert it pops up a message that says you have successfully added blah blah. Then once you click ok it closes the popup page and goes back to the main page. I want to be able to refresh the main page back to how it was when you first land on the page. Here is the code for my insert button:


 <asp:button id="insertButton" 
                    style="background-image:url('Images/Button.gif'); text-align:center;background-color:Transparent; cursor:hand; background-repeat:no-repeat; background-position:left; padding-left:15px; font-family: 'Arial Unicode MS'; font-size: small; font-weight: bold;" 
                    Runat="server" Height="25px" BorderStyle=None ForeColor=White    Text="Insert" 
                    Width="99px" CssClass="style13" CommandName="Insert" OnClientClick="javascript: alert('You have successfully added a New Donor!!');window.open('','_self','');window.close();" />


Maximize page when new Record in GridView


Hi All,

I am trying to to maximize / focus the page when i get new record in my GridView, for this i put the timer to but i can i can see it is nit firing under the timer.

Here is my code.

function maximize() {
  window.moveTo(0, 0);
  window.resizeTo(screen.width, screen.height);

 Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick

	Me.ClientScript.RegisterStartupScript(Me.GetType(), "", "<script language=javascript>maximize();</script>")
        If GridView1.Rows.Count.ToString > Session("total_Row") Then
	     'Me.ClientScript.RegisterStartupScript(Me.GetType(), "", "<script language=javascript>maximize();</script>")
            Session("total_Row") = GridView1.Rows.Count.ToString
        End If

    End Sub

And i am calling RegisterStartupScript outside of timer for the example on push button event it works well. But inside timer it is not firing...

I will appriciate for your suggestions.


Dynamically getting db name from another page


Hello Everyone.... I currently have this code on my page_load event handler and i am trying to figure out if i can put it on another page and call it from there. I have a lot of sql statement on codebehind and when i try to move from dev to prod... i encounter problems a little... Is there a way out... thanks


If Not Page.IsPostBack Then

Dim connString As

Dynamically Loaded UserControl, receiving the click event from UserControl to Parent Page



   In a page , when I click a button 'showDialog' I am loading the user control dynamically in a dialog.  I am linking to the event in the user control as explained below. The parent page is not receiving this event.

  ex: (This is in the page class)


         UseControl1 gc = dlg.LoadContent(:\UserControl1.csx);

        gc.CausePostback += new EventHandler(execute_CausePostback());



   // I am trying to update the details grid in parent page


In UserControl class after clicking the submit button


  raise event CausePostBack();


Any help is appreciated.



Dynamically adding content to page outside of the aspnet form from within a UC


I have a uc which generates a html form  that should auto-submit when the browser loads the page, so I need to add the form to the page before the </body> tag - outside the asp.net form, id like my UC to work without having any requirements on its parent page / masterpage.

i have managed to add a literal inside the body tag by calling the following inside CreateChildControls on the parent page
Me.Form.Parent.Controls.AddAt(0, ltl)
however this required the body to have runat="server" and the code to be added to the user control's parent page. ( this also seems to cause the viewstate to be lost after postback)

Is there any way i can append the string to the rendered html inside the body but outside the <form></form> from within the UC code

Incase it makes a difference the UC is being added dynamically to the page.

How can I change the CSS file used in Master Page dynamically?


I am thinking that it would be better to use multipe CSS files and change them within the master page dynamically than it would be to use multiple master pages (basically one master page for each page, which defeats the purpose of the master page).

However, I do not know how to make a change to the master page before a standard apsx page that is derived from it is loaded.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend