Click here to Skip to main content
15,849,105 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Question Pin
Ashish Sehajpal17-Apr-08 6:59
Ashish Sehajpal17-Apr-08 6:59 
GeneralRe: Question Pin
Vasudevan Deepak Kumar17-Apr-08 22:06
Vasudevan Deepak Kumar17-Apr-08 22:06 
QuestionDropdownlist DataTextField Pin
Saba0217-Apr-08 4:00
Saba0217-Apr-08 4:00 
GeneralRe: Dropdownlist DataTextField Pin
eyeseetee17-Apr-08 4:10
eyeseetee17-Apr-08 4:10 
GeneralRe: Dropdownlist DataTextField Pin
Ashish Sehajpal17-Apr-08 7:02
Ashish Sehajpal17-Apr-08 7:02 
QuestionProcess.Start fails on clustered servers??? Pin
JimFeng17-Apr-08 3:40
JimFeng17-Apr-08 3:40 
AnswerRe: Process.Start fails on clustered servers??? Pin
Vasudevan Deepak Kumar17-Apr-08 23:33
Vasudevan Deepak Kumar17-Apr-08 23:33 
QuestionHow to Add New Row in Gridview Using Ajax Toolkit Pin
Ankit At Codeproject17-Apr-08 3:06
Ankit At Codeproject17-Apr-08 3:06 
Hello
I m Working on gridview.how can i add new row in gridview using ajax toolkit
i had developed it till now like that
i want that on page refresh whatever in the grid till is kept
can anyone help me..

thanks

====aspx page======


]]>





<title>Untitled Page


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (PreviousPage == null)
{

if ("" != (string)Session["AddRow"])
{
btnAddRow();
btnAddRow();
}

else
{
btnDisRow();
}

}
}
else
{

Session["AddRow"] = "Yes";
}

if ("Yes" == (string)Session["AddRow"])
{
btnAddRow();
Session["AddRow"] = "";
}




}









<asp:scriptmanager id="ScriptManager1" runat="server">




<asp:updatepanel id="UpdatePanel1" runat="server">

<contenttemplate>

<asp:gridview id="grdnew" runat="server" enableviewstate="false" style="z-index: 100; <br mode=" hold=" /">left: 53px; position: absolute;top: 81px" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="false">

<footerstyle backcolor="#990000" font-bold="True" forecolor="White">
<rowstyle backcolor="#FFFBD6" forecolor="#333333">
<selectedrowstyle backcolor="#FFCC66" font-bold="True" forecolor="Navy">
<pagerstyle backcolor="#FFCC66" forecolor="#333333" horizontalalign="Center">
<headerstyle backcolor="#990000" font-bold="True" forecolor="White">
<alternatingrowstyle backcolor="White">

<columns>
<asp:templatefield>

<headertemplate>

<asp:label id="lblimg" runat="server" text=" ">
<asp:label id="Label1" runat="server" text="Name">

<asp:label id="Label2" runat="server" text="ContactNo">

<asp:label id="Label3" runat="server" text="Email">

<asp:label id="Label4" runat="server" text="Designation">


<itemtemplate>
<asp:imagebutton id="btnimgadd" runat="server">
ImageUrl="~/add.gif" ToolTip="Add Row" OnClick="Button1_Click" />
<asp:textbox id="TextBox1" runat="server">
EnableViewState="true" Text='<%# Eval("Name")%>' Width ="100px" />
<asp:textbox id="TextBox2" runat="server">
EnableViewState="true" Text='<%# Eval("contactNo")%>' Width ="100px" />
<asp:textbox id="TextBox3" runat="server">
EnableViewState="true" Text='<%# Eval("email")%>' Width ="100px"/>
<asp:textbox id="TextBox4" runat="server">
EnableViewState="true" Text='<%# Eval("designation")%>' Width ="100px" />






<triggers> <asp:asyncpostbacktrigger controlid="bUpdate1" eventname="Click">



<asp:button id="bUpdate1" runat="server" text="Click Here" onclick="bUpdate1_Click">
 
<asp:updateprogress id="UpdateProgress1" runat="server" associatedupdatepanelid="UpdatePanel1">
<progresstemplate>
Getting Data From Server.....








=======cs file=======


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 MySql.Data.MySqlClient;

public partial class Default2 : System.Web.UI.Page
{
DataSet ds;
MySqlConnection mcon;
MySqlCommand mcmd;
MySqlDataAdapter mda;
DataTable dt;
DataRow dr;


protected void btnAddRow()
{

dt = CreateDataTable();
grdnew.DataSource = dt;
grdnew.DataBind();


}
protected void btnDisRow()
{

dt = (DataTable)ViewState["DataTable"];
grdnew.DataSource = dt;
grdnew.DataBind();


}

protected DataTable CreateDataTable()
{
DataTable dtvalues = (DataTable)ViewState["DataTable"];
if (dtvalues == null)
{
dtvalues = new DataTable();
dtvalues.Columns.Add(new DataColumn("", typeof(string)));
dtvalues.Columns.Add(new DataColumn("Name", typeof(string)));
dtvalues.Columns.Add(new DataColumn("contactNo", typeof(string)));
dtvalues.Columns.Add(new DataColumn("email", typeof(string)));
dtvalues.Columns.Add(new DataColumn("designation", typeof(string)));
ViewState["DataTable"] = dtvalues;
}
else
{
dr = dtvalues.NewRow();
dtvalues.Rows.Add(dr);


ViewState["DataTable"] = dtvalues;
}
return dtvalues;
}

protected void bUpdate1_Click(object sender, EventArgs e)
{

}
}
AnswerRe: How to Add New Row in Gridview Using Ajax Toolkit Pin
N a v a n e e t h17-Apr-08 3:16
N a v a n e e t h17-Apr-08 3:16 
GeneralRe: How to Add New Row in Gridview Using Ajax Toolkit Pin
hardnova17-Apr-08 8:02
hardnova17-Apr-08 8:02 
QuestionRe: How to Add New Row in Gridview Using Ajax Toolkit Pin
Ankit At Codeproject17-Apr-08 20:26
Ankit At Codeproject17-Apr-08 20:26 
AnswerRe: How to Add New Row in Gridview Using Ajax Toolkit Pin
Amit Agarrwal17-Apr-08 20:08
Amit Agarrwal17-Apr-08 20:08 
QuestionRe: How to Add New Row in Gridview Using Ajax Toolkit Pin
Ankit At Codeproject17-Apr-08 20:29
Ankit At Codeproject17-Apr-08 20:29 
QuestionWeb service links??? Pin
John Sundar17-Apr-08 2:47
John Sundar17-Apr-08 2:47 
GeneralRe: Web service links??? Pin
N a v a n e e t h17-Apr-08 3:12
N a v a n e e t h17-Apr-08 3:12 
GeneralRe: Web service links??? Pin
Amit Agarrwal17-Apr-08 20:10
Amit Agarrwal17-Apr-08 20:10 
Generalquestion Pin
nithydurai17-Apr-08 2:31
nithydurai17-Apr-08 2:31 
GeneralRe: question Pin
_AK_17-Apr-08 2:34
_AK_17-Apr-08 2:34 
GeneralRe: question Pin
pmarfleet17-Apr-08 2:38
pmarfleet17-Apr-08 2:38 
GeneralRe: question Pin
J4amieC17-Apr-08 2:41
J4amieC17-Apr-08 2:41 
GeneralRe: question Pin
Herman<T>.Instance17-Apr-08 5:14
Herman<T>.Instance17-Apr-08 5:14 
GeneralRe: question Pin
Vasudevan Deepak Kumar17-Apr-08 22:45
Vasudevan Deepak Kumar17-Apr-08 22:45 
GeneralCalling webservice from client side Pin
0905v4917-Apr-08 2:27
0905v4917-Apr-08 2:27 
GeneralRe: Calling webservice from client side Pin
_AK_17-Apr-08 2:30
_AK_17-Apr-08 2:30 
GeneralRe: Calling webservice from client side Pin
0905v4917-Apr-08 2:53
0905v4917-Apr-08 2:53 

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.