Click here to Skip to main content
15,894,405 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Current theme Pin
michaelschmitt15-Apr-10 3:28
michaelschmitt15-Apr-10 3:28 
GeneralRe: Current theme Pin
paper6715-Apr-10 4:54
paper6715-Apr-10 4:54 
GeneralRe: Current theme Pin
michaelschmitt15-Apr-10 6:35
michaelschmitt15-Apr-10 6:35 
GeneralRe: Current theme Pin
paper6715-Apr-10 6:52
paper6715-Apr-10 6:52 
GeneralRe: Current theme Pin
michaelschmitt15-Apr-10 8:00
michaelschmitt15-Apr-10 8:00 
GeneralRe: Current theme Pin
paper6715-Apr-10 8:01
paper6715-Apr-10 8:01 
GeneralRe: Current theme Pin
michaelschmitt15-Apr-10 8:23
michaelschmitt15-Apr-10 8:23 
QuestionAdd HTML table row at run time by clicking a button Pin
_______________________14-Apr-10 4:26
_______________________14-Apr-10 4:26 
I want to add table rows at run time. when i click '+' button on the 1st row, i want to add the column values (in first row) to a database. similarly 2nd, third and so on respectively.



this is the code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="admn_div_hist.aspx.cs" Inherits="Portfolio" %><br />
<br />
<br />
<%@ Register Src="Calendar.ascx" TagName="Calendar" TagPrefix="uc1" %><br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml" ><br />
<head runat="server"><br />
    <title>Portfolio Management System</title><br />
	<script language="javascript" type="text/javascript"><br />
 	 <br />
 <br />
function AddRow()<br />
{<br />
var table = document.getElementById("tblGrid");<br />
if (!table) throw "Table not found";<br />
var row = table.insertRow(-1); <br />
 <br />
//append at the end<br />
var cell1 = row.insertCell(-1);<br />
var cell2 = row.insertCell(-1);<br />
var cell3 = row.insertCell(-1);<br />
 <br />
cell1.innerHTML = "<input type='text' id='div_no'>";<br />
cell2.innerHTML = "<input type='text' id='txt_divdate'> &nbsp;&nbsp;<img src='images/calendar.gif' onclick='caldisplay'>";<br />
cell3.innerHTML = "<input type='text' id='txt_divunits'>";<br />
<br />
<br />
}<br />
 <br />
 function caldisplay()<br />
 {<br />
    var dt=document.getElementById('Calendar1');<br />
    dt.style.display='block';<br />
    <br />
        <br />
 }<br />
<br />
</script><br />
<br />
<body><br />
<form id="frm_dividend_hist" runat="server"><br />
<table id="tblGrid" style="table-layout:fixed; z-index: 107; left: 125px; position: absolute; top: 216px;" border="1" bordercolor="#3399ff" width="270"><br />
			<tr><br />
				<td style="height: 19px; width: 70px;"><br />
                    Dividend #</td><br />
				<td style="height: 19px; width: 120px;"><br />
                    &nbsp;Dividend Date</td><br />
				<td style="height: 19px; width: 80px;"><br />
                    % Units</td><br />
			</tr><br />
          <tr><br />
              <td style="width: 158px; height: 13px"><br />
                  <asp:TextBox ID="div_no" runat="server" Style="z-index: 100; left: 4px; position: absolute;<br />
                      top: 29px" Width="57px" Height="13px"></asp:TextBox><br />
              </td><br />
              <td style="height: 13px; width: 330px;"><br />
                  <asp:TextBox ID="txt_divdate" runat="server" Style="z-index: 100; left: 80px; position: absolute;<br />
                      top: 31px" Width="91px" Height="10px"></asp:TextBox><br />
                       <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/calendar.gif"<br />
               Style="z-index: 105; left: 182px; position: absolute;<br />
            top: 30px" OnClick="ImageButton2_Click1"   /><br />
                 <br />
              </td><br />
              <td style="width: 50px; height: 19px"><br />
               <asp:TextBox ID="txt_divunits" runat="server"   Style="z-index: 102;<br />
                      left: 217px; position: absolute; top: 29px" Width="17px"></asp:TextBox><br />
              <asp:Button ID="Button1" runat="server" Style="z-index: 108; left: 250px; position: absolute;<br />
            top: 29px" Text="+" Width="27px" OnClick="Button1_Click" Height="20px" /><br />
            <br />
                          </td><br />
          </tr><br />
			 <br />
		</table><br />
<br />
		</form><br />
		</table><br />
		 <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999"<br />
            CellPadding="4" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"<br />
            ForeColor="Black" Height="180px" Style="z-index: 105; left: 674px; position: absolute;<br />
            top: 263px" Visible="False" Width="200px" OnSelectionChanged="Calendar1_SelectionChanged"><br />
            <SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" /><br />
            <SelectorStyle BackColor="#CCCCCC" /><br />
            <WeekendDayStyle BackColor="#FFFFCC" /><br />
            <TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" /><br />
            <OtherMonthDayStyle ForeColor="#808080" /><br />
            <NextPrevStyle VerticalAlign="Bottom" /><br />
            <DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" /><br />
            <TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" /><br />
        </asp:Calendar><br />
        </body><br />
		</html><br />



Code Behind page



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Logic;

public partial class Portfolio : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{


}

protected void ImageButton2_Click1(object sender, ImageClickEventArgs e)
{
Calendar1.Visible = true;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
this.txt_divdate.Text = Calendar1.SelectedDate.ToString("d");
Calendar1.Visible = false;

}

protected void Button1_Click(object sender, EventArgs e)
{

this.Button1.Attributes.Add("onclick", "AddRow()");
}

}
AnswerRe: Add HTML table row at run time by clicking a button Pin
Martin Jarvis14-Apr-10 10:58
Martin Jarvis14-Apr-10 10:58 
GeneralRe: Add HTML table row at run time by clicking a button Pin
_______________________14-Apr-10 16:45
_______________________14-Apr-10 16:45 
GeneralRe: Add HTML table row at run time by clicking a button Pin
Martin Jarvis14-Apr-10 23:00
Martin Jarvis14-Apr-10 23:00 
AnswerRe: Add HTML table row at run time by clicking a button Pin
daveyerwin14-Apr-10 12:14
daveyerwin14-Apr-10 12:14 
GeneralRe: Add HTML table row at run time by clicking a button Pin
Martin Jarvis14-Apr-10 23:02
Martin Jarvis14-Apr-10 23:02 
GeneralRe: Add HTML table row at run time by clicking a button Pin
daveyerwin15-Apr-10 1:18
daveyerwin15-Apr-10 1:18 
GeneralRe: Add HTML table row at run time by clicking a button Pin
Martin Jarvis15-Apr-10 1:26
Martin Jarvis15-Apr-10 1:26 
Questionwindow.open The Pop window can be resize as per the content of the page Pin
Sandesh M Patil14-Apr-10 4:02
Sandesh M Patil14-Apr-10 4:02 
AnswerRe: window.open The Pop window can be resize as per the content of the page Pin
michaelschmitt14-Apr-10 5:38
michaelschmitt14-Apr-10 5:38 
GeneralRe: window.open The Pop window can be resize as per the content of the page Pin
Sandesh M Patil14-Apr-10 6:14
Sandesh M Patil14-Apr-10 6:14 
GeneralRe: window.open The Pop window can be resize as per the content of the page Pin
daveyerwin14-Apr-10 7:05
daveyerwin14-Apr-10 7:05 
GeneralRe: window.open The Pop window can be resize as per the content of the page Pin
Sandesh M Patil14-Apr-10 22:33
Sandesh M Patil14-Apr-10 22:33 
GeneralRe: window.open The Pop window can be resize as per the content of the page Pin
michaelschmitt14-Apr-10 23:31
michaelschmitt14-Apr-10 23:31 
QuestionHow to Run 32 bit aspnet 1.1 applications on 64 bit machine. Pin
surender.m14-Apr-10 2:19
surender.m14-Apr-10 2:19 
AnswerRe: How to Run 32 bit aspnet 1.1 applications on 64 bit machine. Pin
Not Active14-Apr-10 2:32
mentorNot Active14-Apr-10 2:32 
GeneralRe: How to Run 32 bit aspnet 1.1 applications on 64 bit machine. Pin
surender.m14-Apr-10 3:05
surender.m14-Apr-10 3:05 
GeneralRe: How to Run 32 bit aspnet 1.1 applications on 64 bit machine. Pin
Not Active14-Apr-10 3:36
mentorNot Active14-Apr-10 3:36 

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.