473,842 Members | 1,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid - Adding Rows

Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that the best method? Do you
have a sample of how to do this?
Nov 17 '05 #1
3 4891
Hi Jim,

There's an article that addresses this subject.

Top Questions about the DataGrid Web Server Control
http://msdn.microsoft.com/library/en...hTopQuestionsA
boutASPNETDataG ridServerContro l.asp

Here is the relevant section.

Adding Columns Dynamically
You can hide and show columns if you know in advance what columns you need.
Sometimes, however, you do not know that until run time. In that case, you
can create columns dynamically and add them to the grid.

To do so, you create an instance of one of the column classes supported by
the grid — BoundColumn, EditCommandColu mn, ButtonColumn, or
HyperlinkColumn . (You can add template columns to the grid, but it is
slightly more complex. For details, see Creating Web Server Control
Templates Programmaticall y.) Set the column's properties, and then add it
to the grid's Columns collection.

The following example shows how to add two bound columns to a grid.

' Visual Basic
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
'Set data-binding properties of the grid
DataGrid1.AutoG enerateColumns = False
DataGrid1.DataS ource = Me.dsBooks1
DataGrid1.DataM ember = "Books"
DataGrid1.DataK eyField = "bookid"

' Add two columns
Dim dgc_id As New BoundColumn()
dgc_id.DataFiel d = "bookid"
dgc_id.HeaderTe xt = "ID"
dgc_id.ItemStyl e.Width = New Unit(80)
DataGrid1.Colum ns.Add(dgc_id)

Dim dgc_title As New BoundColumn()
dgc_title.DataF ield = "title"
dgc_title.Heade rText = "Title"
DataGrid1.Colum ns.Add(dgc_titl e)

Me.SqlDataAdapt er1.Fill(Me.dsB ooks1)
DataGrid1.DataB ind()
End Sub

// C#
private void Button1_Click(o bject sender, System.EventArg s e)
{
DataGrid1.AutoG enerateColumns = false;
DataGrid1.DataS ource = this.dsBooks1;
DataGrid1.DataM ember = "Books";
DataGrid1.DataK eyField = "bookid";

// Add two columns
BoundColumn dgc_id = new BoundColumn();
dgc_id.DataFiel d = "bookid";
dgc_id.HeaderTe xt = "ID";
dgc_id.ItemStyl e.Width = new Unit(80);
DataGrid1.Colum ns.Add(dgc_id);

BoundColumn dgc_title= new BoundColumn();
dgc_title.DataF ield = "title";
dgc_title.Heade rText = "Title";
DataGrid1.Colum ns.Add(dgc_titl e);

this.sqlDataAda pter1.Fill(this .dsBooks1);
DataGrid1.DataB ind();
}
Any time that you add controls to a page dynamically, you have the problem
of persistence. Dynamically-added controls (or in this case, columns) are
not automatically added to the page's view state, so you are obliged to add
logic to the page to make sure the columns are available with each round
trip.

An excellent way to do this is to override the page's LoadViewState method,
which gives you an early opportunity to reestablish columns in the DataGrid
control. Because the LoadViewState method is called before the Page_Load
event is raised, re-adding columns in the LoadViewState method assures that
they are available for normal manipulation by the time any event code runs.

The following example shows how you would expand the previous example to
restore the columns each time the page runs again. As before, the
Button1_Click handler adds two columns to the grid. (In this example, the
event handler calls a separate routine called AddColumns to do so.) In
addition, the page contains a simple Boolean property called
DynamicColumnsA dded indicating whether the grid has had columns added; the
property persists its value in view state. The LoadViewState method first
calls the base class's LoadViewState method, which extracts view state
information and configures controls with it. If columns were previously
added to the grid (as per the DynamicColumnsA dded property), the method
then re-adds them.

' Visual Basic
Private Property DynamicColumnAd ded() As Boolean
Get
If ViewState("Colu mnAdded") Is Nothing Then
Return False
Else
Return True
End If
End Get
Set(ByVal Value As Boolean)
ViewState("Colu mnAdded") = Value
End Set
End Property

Protected Overrides Sub LoadViewState(B yVal savedState As Object)
MyBase.LoadView State(savedStat e)
If Me.DynamicColum nAdded Then
Me.AddColums()
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
' Check property to be sure columns are not added more than once
If Me.DynamicColum nAdded Then
Return
Else
Me.AddColums()
End If
End Sub

Protected Sub AddColums()
' Add two columns
Dim dgc_id As New BoundColumn()
dgc_id.DataFiel d = "instock"
dgc_id.HeaderTe xt = "In Stock?"
dgc_id.ItemStyl e.Width = New Unit(80)
DataGrid1.Colum ns.Add(dgc_id)

Dim dgc_title As New BoundColumn()
dgc_title.DataF ield = "title"
dgc_title.Heade rText = "Title"
DataGrid1.Colum ns.Add(dgc_titl e)
Me.DataGrid1.Da taBind()
Me.DynamicColum nAdded = True
End Sub

// C#
private bool DynamicColumnAd ded{
get
{
object b = ViewState["DynamicColumnA dded"];
return (b == null) ? false : true;
}
set
{
ViewState["DynamicColumnA dded"] = value;
}
}

protected override void LoadViewState(o bject savedState)
{
base.LoadViewSt ate(savedState) ;
if (DynamicColumnA dded)
{
this.AddColumns ();
}
}

private void Button1_Click(o bject sender, System.EventArg s e)
{
if(this.Dynamic ColumnAdded != true)
{
this.AddColumns ();
}
}

private void AddColumns()
{
BoundColumn dgc_id = new BoundColumn();
dgc_id.DataFiel d = "bookid";
dgc_id.HeaderTe xt = "ID";
dgc_id.ItemStyl e.Width = new Unit(80);
DataGrid1.Colum ns.Add(dgc_id);

BoundColumn dgc_title= new BoundColumn();
dgc_title.DataF ield = "title";
dgc_title.Heade rText = "Title";
DataGrid1.Colum ns.Add(dgc_titl e);

this.sqlDataAda pter1.Fill(this .dsBooks1);
DataGrid1.DataB ind();
this.DynamicCol umnAdded = true;
}
Adding New Records to a Data Source Using the DataGrid Control
The DataGrid control allows users to view and edit records, but does not
inherently include the facility to add new ones. However, you can add this
functionality in various ways, all of which involve the following:

Adding a new, blank record to the data source of the grid (in the dataset
or database). If necessary, you will need to assign an ID for the record
and put placeholder values into it for any columns that cannot be null.
Rebinding the DataGrid control to the source.
Putting the grid into edit mode for the new record. You need to be able to
determine where in the grid the new record appears.
Updating the record normally when the user clicks Update, thereby writing
the new record to the source with user-provided values.
The following example shows the process for adding the new record, binding
the grid, and putting it into edit mode. In this example, the data source
is a dataset (DsBooks1 or dsBooks1) containing a table called "Books."

' Visual Basic
Private Sub btnAddRow_Click (ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnAddRow.Click
Dim dr As DataRow = Me.DsBooks1.Boo ks.NewRow
dr("title") = "(New)"
dr("instock") = True
Me.DsBooks1.Boo ks.Rows.InsertA t(dr, 0)
Session("DsBook s") = DsBooks1
DataGrid1.EditI temIndex = 0
DataGrid1.DataB ind()
End Sub

// C#
private void btnAddRow_Click (object sender, System.EventArg s e)
{
DataRow dr = this.dsBooks1.B ooks.NewRow();
dr["title"] = "(New)";
dr["instock"] = true;
this.dsBooks1.B ooks.Rows.Inser tAt(dr, 0);
Session["DsBooks"] = dsBooks1;
DataGrid1.EditI temIndex = 0;
DataGrid1.DataB ind();
}
Some things to notice:

This code runs when a user clicks an Add button somewhere in the page.
The new row is created using the NewRow method. It is then inserted into
the dataset table using the InsertAt method, which allows you to place it
at a specific, predefined location — in this case, as the first record in
the table (that is, the first record in the Rows collection).
Alternatively, you could add it to the end of the table, using the row
count as the value. The important thing is that you know exactly where the
row is in the table.
Because you know that the record is in the first position of the table, you
can set the grid's EditItemIndex value to zero to put the new row into edit
mode. (If you created the row elsewhere in the table, you would set
EditItemIndex to that location instead.)
Because you have a new record in the dataset (but not yet in the database),
you have to keep a copy of the dataset between round trips — you do not
want to refill it from the database and lose the new record. Here, the code
stores it in Session state. You need to reload the dataset from Session
state when the page loads. The following example shows what your Page_Load
handler might look like:
' Visual Basic
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
If Me.IsPostBack Then
DsBooks1 = CType(Session(" DsBooks"), dsBooks)
Else
Me.SqlDataAdapt er1.Fill(Me.DsB ooks1)
Session("DsBook s") = DsBooks1
DataGrid1.DataB ind()
End If
End Sub

// C#
private void Page_Load(objec t sender, System.EventArg s e)
{
if(this.IsPostB ack)
{
dsBooks1 = (dsBooks) Session["DsBooks"];
}
else
{
this.sqlDataAda pter1.Fill(this .dsBooks1);
Session["DsBooks"] = dsBooks1;
this.DataGrid1. DataBind();
}
}
For information about maintaining state, see Web Forms State Management in
the Visual Studio documentation.

You can update the record normally. For an example, see Walkthrough: Using
a DataGrid Web Control to Read and Write Data in the Visual Studio
documentation. After updating the dataset, update the database, then
refresh the dataset. Be sure to save the refreshed dataset to Session state
again. Here is an example of an update handler:

' Visual Basic
Private Sub DataGrid1_Updat eCommand(ByVal source As Object, _
ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.Updat eCommand
Dim dr As Dataset.BooksRo w
'Get a reference to row zero (where the row was inserted)
dr = Me.DsBooks1.Boo ks(0)
Dim tb As TextBox = CType(e.Item.Ce lls(2).Controls (0), TextBox)
dr.title = tb.Text
Dim cb As CheckBox = CType(e.Item.Ce lls(3).Controls (1), CheckBox)
dr.instock = cb.Checked
Me.SqlDataAdapt er1.Update(Me.D sBooks1)
DataGrid1.EditI temIndex = -1
'Refresh the dataset from the database
DsBooks1.Clear( )
Me.SqlDataAdapt er1.Fill(Me.DsB ooks1)
'Save the refreshed dataset in Session state agin
Session("DsBook s") = DsBooks1
DataGrid1.DataB ind()
End Sub

// C#
private void DataGrid1_Updat eCommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
dsBooks.BooksRo w dr;
//Get a reference to row zero (where the row was inserted)
dr = this.dsBooks1.B ooks[0];
TextBox tb1 = (TextBox) e.Item.Cells[2].Controls[0];
dr.title = tb1.Text;
CheckBox cb = (CheckBox) e.Item.Cells[3].Controls[1];
dr.instock = cb.Checked;
this.sqlDataAda pter1.Update(th is.dsBooks1);
DataGrid1.EditI temIndex = -1;
//Refresh the dataset from the database
dsBooks1.Clear( );
this.sqlDataAda pter1.Fill(this .dsBooks1);
//Save the refreshed dataset in Session state agin
Session["DsBooks"] = dsBooks1;
DataGrid1.DataB ind();
}
Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Jim Heavey" <an*******@disc ussions.microso ft.com>
Sender: "Jim Heavey" <an*******@disc ussions.microso ft.com>
Subject: DataGrid - Adding Rows
Date: Thu, 13 Nov 2003 05:46:54 -0800
Lines: 5
Message-ID: <0e************ *************** *@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOp7JlDGa9FRO6 BRD68/L+nUe3T9Q==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1906 35
NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that the best method? Do you
have a sample of how to do this?


Nov 17 '05 #2
Thanks, but I was not looking for an example of how to
add a row to the datasource, but rather, I was looking
for how to trigger the adding of a row. I realize that I
could add a button to the form, but I thought it would be
much more visually appealing to add a button to the
footer and my question was how to do this.

Sorry for the confusion.
-----Original Message-----
Hi Jim,

There's an article that addresses this subject.

Top Questions about the DataGrid Web Server Control
http://msdn.microsoft.com/library/en- us/dv_vstechart/html/vbtchTopQuestio nsAboutASPNETData GridServerContr ol.asp

Here is the relevant section.

Adding Columns Dynamically
You can hide and show columns if you know in advance what columns you need.Sometimes, however, you do not know that until run time. In that case, youcan create columns dynamically and add them to the grid.

To do so, you create an instance of one of the column classes supported bythe grid - BoundColumn, EditCommandColu mn, ButtonColumn, orHyperlinkColum n. (You can add template columns to the grid, but it isslightly more complex. For details, see Creating Web Server ControlTemplates Programmaticall y.) Set the column's properties, and then add itto the grid's Columns collection.

The following example shows how to add two bound columns to a grid.
' Visual Basic
Private Sub Button1_Click(B yVal sender As System.Object, _ ByVal e As System.EventArg s) Handles Button1.Click
'Set data-binding properties of the grid
DataGrid1.AutoG enerateColumns = False
DataGrid1.DataS ource = Me.dsBooks1
DataGrid1.DataM ember = "Books"
DataGrid1.DataK eyField = "bookid"

' Add two columns
Dim dgc_id As New BoundColumn()
dgc_id.DataFiel d = "bookid"
dgc_id.HeaderTe xt = "ID"
dgc_id.ItemStyl e.Width = New Unit(80)
DataGrid1.Colum ns.Add(dgc_id)

Dim dgc_title As New BoundColumn()
dgc_title.DataF ield = "title"
dgc_title.Heade rText = "Title"
DataGrid1.Colum ns.Add(dgc_titl e)

Me.SqlDataAdapt er1.Fill(Me.dsB ooks1)
DataGrid1.DataB ind()
End Sub

// C#
private void Button1_Click(o bject sender, System.EventArg s e){
DataGrid1.AutoG enerateColumns = false;
DataGrid1.DataS ource = this.dsBooks1;
DataGrid1.DataM ember = "Books";
DataGrid1.DataK eyField = "bookid";

// Add two columns
BoundColumn dgc_id = new BoundColumn();
dgc_id.DataFiel d = "bookid";
dgc_id.HeaderTe xt = "ID";
dgc_id.ItemStyl e.Width = new Unit(80);
DataGrid1.Colum ns.Add(dgc_id);

BoundColumn dgc_title= new BoundColumn();
dgc_title.DataF ield = "title";
dgc_title.Heade rText = "Title";
DataGrid1.Colum ns.Add(dgc_titl e);

this.sqlDataAda pter1.Fill(this .dsBooks1);
DataGrid1.DataB ind();
}
Any time that you add controls to a page dynamically, you have the problemof persistence. Dynamically-added controls (or in this case, columns) arenot automatically added to the page's view state, so you are obliged to addlogic to the page to make sure the columns are available with each roundtrip.

An excellent way to do this is to override the page's LoadViewState method,which gives you an early opportunity to reestablish columns in the DataGridcontrol. Because the LoadViewState method is called before the Page_Loadevent is raised, re-adding columns in the LoadViewState method assures thatthey are available for normal manipulation by the time any event code runs.
The following example shows how you would expand the previous example torestore the columns each time the page runs again. As before, theButton1_Clic k handler adds two columns to the grid. (In this example, theevent handler calls a separate routine called AddColumns to do so.) Inaddition, the page contains a simple Boolean property calledDynamicColumns Added indicating whether the grid has had columns added; theproperty persists its value in view state. The LoadViewState method firstcalls the base class's LoadViewState method, which extracts view stateinformation and configures controls with it. If columns were previouslyadded to the grid (as per the DynamicColumnsA dded property), the methodthen re-adds them.

' Visual Basic
Private Property DynamicColumnAd ded() As Boolean
Get
If ViewState("Colu mnAdded") Is Nothing Then
Return False
Else
Return True
End If
End Get
Set(ByVal Value As Boolean)
ViewState("Colu mnAdded") = Value
End Set
End Property

Protected Overrides Sub LoadViewState(B yVal savedState As Object) MyBase.LoadView State(savedStat e)
If Me.DynamicColum nAdded Then
Me.AddColums()
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, _ ByVal e As System.EventArg s) Handles Button1.Click
' Check property to be sure columns are not added more than once If Me.DynamicColum nAdded Then
Return
Else
Me.AddColums()
End If
End Sub

Protected Sub AddColums()
' Add two columns
Dim dgc_id As New BoundColumn()
dgc_id.DataFiel d = "instock"
dgc_id.HeaderTe xt = "In Stock?"
dgc_id.ItemStyl e.Width = New Unit(80)
DataGrid1.Colum ns.Add(dgc_id)

Dim dgc_title As New BoundColumn()
dgc_title.DataF ield = "title"
dgc_title.Heade rText = "Title"
DataGrid1.Colum ns.Add(dgc_titl e)
Me.DataGrid1.Da taBind()
Me.DynamicColum nAdded = True
End Sub

// C#
private bool DynamicColumnAd ded{
get
{
object b = ViewState["DynamicColumnA dded"];
return (b == null) ? false : true;
}
set
{
ViewState["DynamicColumnA dded"] = value;
}
}

protected override void LoadViewState(o bject savedState)
{
base.LoadViewSt ate(savedState) ;
if (DynamicColumnA dded)
{
this.AddColumns ();
}
}

private void Button1_Click(o bject sender, System.EventArg s e){
if(this.Dynamic ColumnAdded != true)
{
this.AddColumns ();
}
}

private void AddColumns()
{
BoundColumn dgc_id = new BoundColumn();
dgc_id.DataFiel d = "bookid";
dgc_id.HeaderTe xt = "ID";
dgc_id.ItemStyl e.Width = new Unit(80);
DataGrid1.Colum ns.Add(dgc_id);

BoundColumn dgc_title= new BoundColumn();
dgc_title.DataF ield = "title";
dgc_title.Heade rText = "Title";
DataGrid1.Colum ns.Add(dgc_titl e);

this.sqlDataAda pter1.Fill(this .dsBooks1);
DataGrid1.DataB ind();
this.DynamicCol umnAdded = true;
}
Adding New Records to a Data Source Using the DataGrid ControlThe DataGrid control allows users to view and edit records, but does notinherently include the facility to add new ones. However, you can add thisfunctionalit y in various ways, all of which involve the following:
Adding a new, blank record to the data source of the grid (in the datasetor database). If necessary, you will need to assign an ID for the recordand put placeholder values into it for any columns that cannot be null.Rebinding the DataGrid control to the source.
Putting the grid into edit mode for the new record. You need to be able todetermine where in the grid the new record appears.
Updating the record normally when the user clicks Update, thereby writingthe new record to the source with user-provided values.
The following example shows the process for adding the new record, bindingthe grid, and putting it into edit mode. In this example, the data sourceis a dataset (DsBooks1 or dsBooks1) containing a table called "Books."
' Visual Basic
Private Sub btnAddRow_Click (ByVal sender As System.Object, _ ByVal e As System.EventArg s) Handles btnAddRow.Click Dim dr As DataRow = Me.DsBooks1.Boo ks.NewRow
dr("title") = "(New)"
dr("instock") = True
Me.DsBooks1.Boo ks.Rows.InsertA t(dr, 0)
Session("DsBook s") = DsBooks1
DataGrid1.EditI temIndex = 0
DataGrid1.DataB ind()
End Sub

// C#
private void btnAddRow_Click (object sender, System.EventArg s e){
DataRow dr = this.dsBooks1.B ooks.NewRow();
dr["title"] = "(New)";
dr["instock"] = true;
this.dsBooks1.B ooks.Rows.Inser tAt(dr, 0);
Session["DsBooks"] = dsBooks1;
DataGrid1.EditI temIndex = 0;
DataGrid1.DataB ind();
}
Some things to notice:

This code runs when a user clicks an Add button somewhere in the page.The new row is created using the NewRow method. It is then inserted intothe dataset table using the InsertAt method, which allows you to place itat a specific, predefined location - in this case, as the first record inthe table (that is, the first record in the Rows collection).Alternativel y, you could add it to the end of the table, using the rowcount as the value. The important thing is that you know exactly where therow is in the table.
Because you know that the record is in the first position of the table, youcan set the grid's EditItemIndex value to zero to put the new row into editmode. (If you created the row elsewhere in the table, you would setEditItemInde x to that location instead.)
Because you have a new record in the dataset (but not yet in the database),you have to keep a copy of the dataset between round trips - you do notwant to refill it from the database and lose the new record. Here, the codestores it in Session state. You need to reload the dataset from Sessionstate when the page loads. The following example shows what your Page_Loadhandler might look like:
' Visual Basic
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
If Me.IsPostBack Then
DsBooks1 = CType(Session(" DsBooks"), dsBooks)
Else
Me.SqlDataAdapt er1.Fill(Me.DsB ooks1)
Session("DsBook s") = DsBooks1
DataGrid1.DataB ind()
End If
End Sub

// C#
private void Page_Load(objec t sender, System.EventArg s e)
{
if(this.IsPostB ack)
{
dsBooks1 = (dsBooks) Session["DsBooks"];
}
else
{
this.sqlDataAda pter1.Fill(this .dsBooks1);
Session["DsBooks"] = dsBooks1;
this.DataGrid1. DataBind();
}
}
For information about maintaining state, see Web Forms State Management inthe Visual Studio documentation.

You can update the record normally. For an example, see Walkthrough: Usinga DataGrid Web Control to Read and Write Data in the Visual Studiodocumentatio n. After updating the dataset, update the database, thenrefresh the dataset. Be sure to save the refreshed dataset to Session stateagain. Here is an example of an update handler:

' Visual Basic
Private Sub DataGrid1_Updat eCommand(ByVal source As Object, _ ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _ Handles DataGrid1.Updat eCommand
Dim dr As Dataset.BooksRo w
'Get a reference to row zero (where the row was inserted) dr = Me.DsBooks1.Boo ks(0)
Dim tb As TextBox = CType(e.Item.Ce lls(2).Controls (0), TextBox) dr.title = tb.Text
Dim cb As CheckBox = CType(e.Item.Ce lls(3).Controls (1), CheckBox) dr.instock = cb.Checked
Me.SqlDataAdapt er1.Update(Me.D sBooks1)
DataGrid1.EditI temIndex = -1
'Refresh the dataset from the database
DsBooks1.Clear( )
Me.SqlDataAdapt er1.Fill(Me.DsB ooks1)
'Save the refreshed dataset in Session state agin
Session("DsBook s") = DsBooks1
DataGrid1.DataB ind()
End Sub

// C#
private void DataGrid1_Updat eCommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e){
dsBooks.BooksRo w dr;
//Get a reference to row zero (where the row was inserted) dr = this.dsBooks1.B ooks[0];
TextBox tb1 = (TextBox) e.Item.Cells[2].Controls[0];
dr.title = tb1.Text;
CheckBox cb = (CheckBox) e.Item.Cells[3].Controls[1];
dr.instock = cb.Checked;
this.sqlDataAda pter1.Update(th is.dsBooks1);
DataGrid1.EditI temIndex = -1;
//Refresh the dataset from the database
dsBooks1.Clear( );
this.sqlDataAda pter1.Fill(this .dsBooks1);
//Save the refreshed dataset in Session state agin
Session["DsBooks"] = dsBooks1;
DataGrid1.DataB ind();
}
Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit thehttp://www.microsoft.com/protect site and perform the three straightforwardsteps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Jim Heavey" <an*******@disc ussions.microso ft.com> Sender: "Jim Heavey" <an*******@disc ussions.microso ft.com> Subject: DataGrid - Adding Rows
Date: Thu, 13 Nov 2003 05:46:54 -0800
Lines: 5
Message-ID: <0e************ *************** *@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOp7JlDGa9FRO6 BRD68/L+nUe3T9Q==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1906 35 NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that the best method? Do you
have a sample of how to do this?


.

Nov 17 '05 #3
Hi Jim,

I couldn't find any direct way to do what you want. However, I did find a
workaround using a hidden field. Here's my sample code which uses the Pubs
database.

The HTML

A grid with one template column & a button in the footer template of that
column. Then a hidden field named "h" with runat=server.

<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" runat="server" ShowFooter="Tru e">
<Columns>
<asp:TemplateCo lumn>
<FooterTemplate >
<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
</FooterTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid><I NPUT type="hidden" id="h" runat="server">
</form>

The Code-Behind

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
Bind()
Else
Response.Write( h.Value)
h.Value = ""
End If
End Sub

Private Sub Bind()
Dim Qry1 As System.Data.Sql Client.SqlDataR eader
Dim connectionStrin g As String = "server='localh ost';
trusted_connect ion=true; Database='pubs' "
Dim sqlConnection As System.Data.Sql Client.SqlConne ction = New
System.Data.Sql Client.SqlConne ction(connectio nString)
Dim queryString As String = "SELECT au_id, au_lname, au_fname FROM
authors"
Dim sqlCommand As System.Data.Sql Client.SqlComma nd = New
System.Data.Sql Client.SqlComma nd(queryString, sqlConnection)
sqlConnection.O pen()
Qry1 =
sqlCommand.Exec uteReader(Syste m.Data.CommandB ehavior.CloseCo nnection)
DataGrid1.DataS ource = Qry1
DataGrid1.DataB ind()
Qry1.Close()
sqlCommand.Disp ose()
sqlConnection.C lose()
sqlConnection.D ispose()
End Sub

Private Sub DataGrid1_ItemD ataBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
DataGrid1.ItemD ataBound
If e.Item.ItemType = ListItemType.Fo oter Then
CType(e.Item.Ce lls(0).Controls (1),
WebControls.But ton).Attributes .Add("onclick", "document.all(' h').value =
'click'")
End If
End Sub
Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Jim Heavey" <an*******@disc ussions.microso ft.com>
Sender: "Jim Heavey" <an*******@disc ussions.microso ft.com>
References: <0e************ *************** *@phx.gbl> <FN************ **@cpmsftngxa06 .phx.gbl> Subject: RE: DataGrid - Adding Rows
Date: Thu, 13 Nov 2003 12:01:36 -0800
Lines: 461
Message-ID: <03************ *************** *@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcOqIPGTqfIjfLQ nRFuR4w0rvk/WVA==
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1907 53
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

Thanks, but I was not looking for an example of how to
add a row to the datasource, but rather, I was looking
for how to trigger the adding of a row. I realize that I
could add a button to the form, but I thought it would be
much more visually appealing to add a button to the
footer and my question was how to do this.

Sorry for the confusion.
-----Original Message-----
Hi Jim,

There's an article that addresses this subject.

Top Questions about the DataGrid Web Server Control
http://msdn.microsoft.com/library/en-

us/dv_vstechart/html/vbtchTopQuestio nsA
boutASPNETData GridServerContr ol.asp

Here is the relevant section.

Adding Columns Dynamically
You can hide and show columns if you know in advance

what columns you need.
Sometimes, however, you do not know that until run time.

In that case, you
can create columns dynamically and add them to the grid.

To do so, you create an instance of one of the column

classes supported by
the grid - BoundColumn, EditCommandColu mn, ButtonColumn,

or
HyperlinkColum n. (You can add template columns to the

grid, but it is
slightly more complex. For details, see Creating Web

Server Control
Templates Programmaticall y.) Set the column's

properties, and then add it
to the grid's Columns collection.

The following example shows how to add two bound columns

to a grid.

' Visual Basic
Private Sub Button1_Click(B yVal sender As System.Object,

_
ByVal e As System.EventArg s) Handles Button1.Click
'Set data-binding properties of the grid
DataGrid1.AutoG enerateColumns = False
DataGrid1.DataS ource = Me.dsBooks1
DataGrid1.DataM ember = "Books"
DataGrid1.DataK eyField = "bookid"

' Add two columns
Dim dgc_id As New BoundColumn()
dgc_id.DataFiel d = "bookid"
dgc_id.HeaderTe xt = "ID"
dgc_id.ItemStyl e.Width = New Unit(80)
DataGrid1.Colum ns.Add(dgc_id)

Dim dgc_title As New BoundColumn()
dgc_title.DataF ield = "title"
dgc_title.Heade rText = "Title"
DataGrid1.Colum ns.Add(dgc_titl e)

Me.SqlDataAdapt er1.Fill(Me.dsB ooks1)
DataGrid1.DataB ind()
End Sub

// C#
private void Button1_Click(o bject sender,

System.EventArg s e)
{
DataGrid1.AutoG enerateColumns = false;
DataGrid1.DataS ource = this.dsBooks1;
DataGrid1.DataM ember = "Books";
DataGrid1.DataK eyField = "bookid";

// Add two columns
BoundColumn dgc_id = new BoundColumn();
dgc_id.DataFiel d = "bookid";
dgc_id.HeaderTe xt = "ID";
dgc_id.ItemStyl e.Width = new Unit(80);
DataGrid1.Colum ns.Add(dgc_id);

BoundColumn dgc_title= new BoundColumn();
dgc_title.DataF ield = "title";
dgc_title.Heade rText = "Title";
DataGrid1.Colum ns.Add(dgc_titl e);

this.sqlDataAda pter1.Fill(this .dsBooks1);
DataGrid1.DataB ind();
}
Any time that you add controls to a page dynamically,

you have the problem
of persistence. Dynamically-added controls (or in this

case, columns) are
not automatically added to the page's view state, so you

are obliged to add
logic to the page to make sure the columns are available

with each round
trip.

An excellent way to do this is to override the page's

LoadViewState method,
which gives you an early opportunity to reestablish

columns in the DataGrid
control. Because the LoadViewState method is called

before the Page_Load
event is raised, re-adding columns in the LoadViewState

method assures that
they are available for normal manipulation by the time

any event code runs.

The following example shows how you would expand the

previous example to
restore the columns each time the page runs again. As

before, the
Button1_Clic k handler adds two columns to the grid. (In

this example, the
event handler calls a separate routine called AddColumns

to do so.) In
addition, the page contains a simple Boolean property

called
DynamicColumns Added indicating whether the grid has had

columns added; the
property persists its value in view state. The

LoadViewState method first
calls the base class's LoadViewState method, which

extracts view state
information and configures controls with it. If columns

were previously
added to the grid (as per the DynamicColumnsA dded

property), the method
then re-adds them.

' Visual Basic
Private Property DynamicColumnAd ded() As Boolean
Get
If ViewState("Colu mnAdded") Is Nothing Then
Return False
Else
Return True
End If
End Get
Set(ByVal Value As Boolean)
ViewState("Colu mnAdded") = Value
End Set
End Property

Protected Overrides Sub LoadViewState(B yVal savedState

As Object)
MyBase.LoadView State(savedStat e)
If Me.DynamicColum nAdded Then
Me.AddColums()
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object,

_
ByVal e As System.EventArg s) Handles Button1.Click
' Check property to be sure columns are not added

more than once
If Me.DynamicColum nAdded Then
Return
Else
Me.AddColums()
End If
End Sub

Protected Sub AddColums()
' Add two columns
Dim dgc_id As New BoundColumn()
dgc_id.DataFiel d = "instock"
dgc_id.HeaderTe xt = "In Stock?"
dgc_id.ItemStyl e.Width = New Unit(80)
DataGrid1.Colum ns.Add(dgc_id)

Dim dgc_title As New BoundColumn()
dgc_title.DataF ield = "title"
dgc_title.Heade rText = "Title"
DataGrid1.Colum ns.Add(dgc_titl e)
Me.DataGrid1.Da taBind()
Me.DynamicColum nAdded = True
End Sub

// C#
private bool DynamicColumnAd ded{
get
{
object b = ViewState["DynamicColumnA dded"];
return (b == null) ? false : true;
}
set
{
ViewState["DynamicColumnA dded"] = value;
}
}

protected override void LoadViewState(o bject savedState)
{
base.LoadViewSt ate(savedState) ;
if (DynamicColumnA dded)
{
this.AddColumns ();
}
}

private void Button1_Click(o bject sender,

System.EventArg s e)
{
if(this.Dynamic ColumnAdded != true)
{
this.AddColumns ();
}
}

private void AddColumns()
{
BoundColumn dgc_id = new BoundColumn();
dgc_id.DataFiel d = "bookid";
dgc_id.HeaderTe xt = "ID";
dgc_id.ItemStyl e.Width = new Unit(80);
DataGrid1.Colum ns.Add(dgc_id);

BoundColumn dgc_title= new BoundColumn();
dgc_title.DataF ield = "title";
dgc_title.Heade rText = "Title";
DataGrid1.Colum ns.Add(dgc_titl e);

this.sqlDataAda pter1.Fill(this .dsBooks1);
DataGrid1.DataB ind();
this.DynamicCol umnAdded = true;
}
Adding New Records to a Data Source Using the DataGrid

Control
The DataGrid control allows users to view and edit

records, but does not
inherently include the facility to add new ones.

However, you can add this
functionalit y in various ways, all of which involve the

following:

Adding a new, blank record to the data source of the

grid (in the dataset
or database). If necessary, you will need to assign an

ID for the record
and put placeholder values into it for any columns that

cannot be null.
Rebinding the DataGrid control to the source.
Putting the grid into edit mode for the new record. You

need to be able to
determine where in the grid the new record appears.
Updating the record normally when the user clicks

Update, thereby writing
the new record to the source with user-provided values.
The following example shows the process for adding the

new record, binding
the grid, and putting it into edit mode. In this

example, the data source
is a dataset (DsBooks1 or dsBooks1) containing a table

called "Books."

' Visual Basic
Private Sub btnAddRow_Click (ByVal sender As

System.Object, _
ByVal e As System.EventArg s) Handles

btnAddRow.Click
Dim dr As DataRow = Me.DsBooks1.Boo ks.NewRow
dr("title") = "(New)"
dr("instock") = True
Me.DsBooks1.Boo ks.Rows.InsertA t(dr, 0)
Session("DsBook s") = DsBooks1
DataGrid1.EditI temIndex = 0
DataGrid1.DataB ind()
End Sub

// C#
private void btnAddRow_Click (object sender,

System.EventArg s e)
{
DataRow dr = this.dsBooks1.B ooks.NewRow();
dr["title"] = "(New)";
dr["instock"] = true;
this.dsBooks1.B ooks.Rows.Inser tAt(dr, 0);
Session["DsBooks"] = dsBooks1;
DataGrid1.EditI temIndex = 0;
DataGrid1.DataB ind();
}
Some things to notice:

This code runs when a user clicks an Add button

somewhere in the page.
The new row is created using the NewRow method. It is

then inserted into
the dataset table using the InsertAt method, which

allows you to place it
at a specific, predefined location - in this case, as

the first record in
the table (that is, the first record in the Rows

collection).
Alternativel y, you could add it to the end of the table,

using the row
count as the value. The important thing is that you know

exactly where the
row is in the table.
Because you know that the record is in the first

position of the table, you
can set the grid's EditItemIndex value to zero to put

the new row into edit
mode. (If you created the row elsewhere in the table,

you would set
EditItemInde x to that location instead.)
Because you have a new record in the dataset (but not

yet in the database),
you have to keep a copy of the dataset between round

trips - you do not
want to refill it from the database and lose the new

record. Here, the code
stores it in Session state. You need to reload the

dataset from Session
state when the page loads. The following example shows

what your Page_Load
handler might look like:
' Visual Basic
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
If Me.IsPostBack Then
DsBooks1 = CType(Session(" DsBooks"), dsBooks)
Else
Me.SqlDataAdapt er1.Fill(Me.DsB ooks1)
Session("DsBook s") = DsBooks1
DataGrid1.DataB ind()
End If
End Sub

// C#
private void Page_Load(objec t sender, System.EventArg s e)
{
if(this.IsPostB ack)
{
dsBooks1 = (dsBooks) Session["DsBooks"];
}
else
{
this.sqlDataAda pter1.Fill(this .dsBooks1);
Session["DsBooks"] = dsBooks1;
this.DataGrid1. DataBind();
}
}
For information about maintaining state, see Web Forms

State Management in
the Visual Studio documentation.

You can update the record normally. For an example, see

Walkthrough: Using
a DataGrid Web Control to Read and Write Data in the

Visual Studio
documentatio n. After updating the dataset, update the

database, then
refresh the dataset. Be sure to save the refreshed

dataset to Session state
again. Here is an example of an update handler:

' Visual Basic
Private Sub DataGrid1_Updat eCommand(ByVal source As

Object, _
ByVal e As

System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.Updat eCommand
Dim dr As Dataset.BooksRo w
'Get a reference to row zero (where the row was

inserted)
dr = Me.DsBooks1.Boo ks(0)
Dim tb As TextBox = CType(e.Item.Ce lls(2).Controls

(0), TextBox)
dr.title = tb.Text
Dim cb As CheckBox = CType(e.Item.Ce lls(3).Controls

(1), CheckBox)
dr.instock = cb.Checked
Me.SqlDataAdapt er1.Update(Me.D sBooks1)
DataGrid1.EditI temIndex = -1
'Refresh the dataset from the database
DsBooks1.Clear( )
Me.SqlDataAdapt er1.Fill(Me.DsB ooks1)
'Save the refreshed dataset in Session state agin
Session("DsBook s") = DsBooks1
DataGrid1.DataB ind()
End Sub

// C#
private void DataGrid1_Updat eCommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs

e)
{
dsBooks.BooksRo w dr;
//Get a reference to row zero (where the row was

inserted)
dr = this.dsBooks1.B ooks[0];
TextBox tb1 = (TextBox) e.Item.Cells[2].Controls[0];
dr.title = tb1.Text;
CheckBox cb = (CheckBox) e.Item.Cells[3].Controls[1];
dr.instock = cb.Checked;
this.sqlDataAda pter1.Update(th is.dsBooks1);
DataGrid1.EditI temIndex = -1;
//Refresh the dataset from the database
dsBooks1.Clear( );
this.sqlDataAda pter1.Fill(this .dsBooks1);
//Save the refreshed dataset in Session state agin
Session["DsBooks"] = dsBooks1;
DataGrid1.DataB ind();
}
Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers

that they visit the
http://www.microsoft.com/protect site and perform the

three straightforward
steps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties,

and confers no rights.


--------------------
Content-Class: urn:content-classes:message
From: "Jim Heavey" <an*******@disc ussions.microso ft.com> Sender: "Jim Heavey" <an*******@disc ussions.microso ft.com> Subject: DataGrid - Adding Rows
Date: Thu, 13 Nov 2003 05:46:54 -0800
Lines: 5
Message-ID: <0e************ *************** *@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOp7JlDGa9FRO6 BRD68/L+nUe3T9Q==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1906 35 NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that the best method? Do you
have a sample of how to do this?


.


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3645
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete a row. Everything works just fine. BUT I would like to add a button to (for example) the DataGrid header, which when pressed will add a new row to the datagrid. This should then allow the user to enter information into text boxes (in some...
0
2478
by: sameer mowade via .NET 247 | last post by:
Hello All, I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically added row it also removes the row at the end along with the added row. Plz tell me if, I am missing any thing. Code </asp:datagrid>
1
3303
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple days of struggling, I figure asking you all (the experts) will keep me from going down some dark and dangerous road. The project I have is a fairly simple one, in theory anyway. The gist is to create a page where the user enters an IDNumber,...
2
1969
by: Praveen Balanagendra via .NET 247 | last post by:
here is the source code private void AddRow() { TableCell tc = new TableCell(); tc.Controls.Add(new LiteralControl("NewRow")); DataGridItem di = new DataGridItem(DataGrid1.Items.Count+1,DataGrid1.Items.Count+1,ListItemType.Item); di.Cells.Add(tc); di.Cells.Add(tc1);
4
3503
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a snippet from my .css file: *************************** body { margin:0; padding:0;
10
8148
by: Aaron Smith | last post by:
If I have a datagrid and the bound data file only have 4 rows in it, the grid will show the 4 rows. However, there is blank space below that until it reaches the bottom of the grid. Is there a way to have a fixed number of rows regardless of what data is in the bound table? Thanks, Aaron -- --- Aaron Smith
2
3573
by: Flack | last post by:
Hey guys, I have a DataGrid and DataTable field in my class : private ImageDataGrid dataGrid1; //ImageDataGrid extends dataGrid and just overides OnMouseDown private DataTable dt = new DataTable("MyTable"); In the classes constructor, after InitializeComponent() I call the following
13
2465
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever works best) to display a dropdown menu of fields populated from table tblInvoiceData. This control also includes a textbox which the user can input a value. These two columns are side by side and not in a vertical layout. The user then clicks on...
12
6239
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the datagrid. Once I can get to that point I need some way to be able to add new data only to the new columns that were added. Here is some of my code: //Function For Importing Data From CSV File public DataSet ConnectCSV(string filetable)
0
9876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10952
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10618
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9459
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7045
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5699
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4506
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4096
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.