Here is the whole code. I hope this helps.
Thanks,
dave
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Configur ation;
using System.Data.Ole Db;
namespace Type3CTracking
{
/// <summary>
/// Summary description for MRDetailsForm.
/// </summary>
public class MRDetailsForm : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l
mrLabel;
protected System.Web.UI.W ebControls.Pane l
Panel1;
protected
System.Web.UI.W ebControls.Text Box mrText;
protected DataGrid workorderGrid = new
DataGrid();
protected System.Web.UI.W ebControls.Labe l
workorderLabel;
protected
System.Web.UI.W ebControls.Plac eHolder workorderHolder ;
protected
System.Data.Ole Db.OleDbDataAda pter oda;
private void Page_Load(objec t sender,
System.EventArg s e)
{
string mr = Request["MR"];
mrText.Text = mr;
if (!IsPostBack)
{
workorderHolder .Controls.Add(M akeWorkorderGri d());
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required
by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new
System.EventHan dler(this.Page_ Load);
}
#endregion
public DataView CreateWorkorder DataSource()
{
string workorderConnec t
= "Provider=\"MSD AORA.1\";User ID=dave;Data
Source=demo;Pas sword=xxxxxxxx" ;
string workorderSelect = "Select
MR.Mrnum, Mrline.Mrlinenu m, Workorder.Wonum ,
Workorder.Descr iption from" +
" MR, Mrline, Workorder
where MR.Mrnum = Mrline.Mrnum and Mrline.Wonum =
Workorder.Wonum " +
" and MR.Mrnum = " + "'" +
mrText.Text + "'";
oda = new OleDbDataAdapte r
(workorderSelec t, workorderConnec t);
DataSet ds = new DataSet();
oda.Fill(ds, "workorder" );
DataView workorder = ds.Tables
["workorder"].DefaultView;
return workorder;
}
public DataGrid MakeWorkorderGr id()
{
//make the DataGrid
workorderGrid.C ellPadding = 2;
workorderGrid.C ellSpacing = 0;
workorderGrid.W idth = 700;
workorderGrid.B orderWidth = 1;
workorderGrid.B orderColor =
Color.Black;
//turn off autogeneratecol umns
feature
workorderGrid.A utoGenerateColu mns
= false;
workorderGrid.F oreColor =
Color.Blue;
workorderGrid.F ont.Size = 10;
workorderGrid.F ont.Name = "Arial";
//sets the HeaderStyle
workorderGrid.H eaderStyle.Back Color = Color.Gold;
workorderGrid.H eaderStyle.Fore Color = Color.Blue;
workorderGrid.H eaderStyle.Font .Name = "Arial";
workorderGrid.H eaderStyle.Font .Size = 10;
workorderGrid.H eaderStyle.Font .Bold = true;
workorderGrid.H eaderStyle.Hori zontalAlign =
HorizontalAlign .Center;
//sets alternating style
workorderGrid.A lternatingItemS tyle.BackColor =
Color.Silver;
workorderGrid.A lternatingItemS tyle.ForeColor =
Color.Black;
//sets the itemstyle
workorderGrid.I temStyle.Horizo ntalAlign =
HorizontalAlign .Center;
//create the bound columns
BoundColumn Wonum = new BoundColumn
();
BoundColumn Mrlinenum = new
BoundColumn();
BoundColumn Desc = new BoundColumn
();
Wonum.HeaderTex t = "Wonum";
Wonum.DataField = "Wonum";
Mrlinenum.Heade rText = "MR Line
Number";
Mrlinenum.DataF ield = "Mrlinenum" ;
Desc.HeaderText = "Descriptio n";
Desc.DataField = "Descriptio n";
//add bound columns to datagrid
workorderGrid.C olumns.AddAt(0,
Wonum);
workorderGrid.C olumns
[0].ItemStyle.Widt h = 20;
workorderGrid.C olumns.AddAt(1,
Mrlinenum);
workorderGrid.C olumns
[1].ItemStyle.Widt h = 100;
workorderGrid.C olumns.AddAt(2,
Desc);
//add a LinkButton column
ButtonColumn bc = new ButtonColumn
();
bc.ButtonType =
ButtonColumnTyp e.LinkButton;
bc.Text = "Click to View workorder
details";
bc.CommandName = "Details";
workorderGrid.C olumns.Add(bc);
workorderGrid.C olumns
[3].HeaderText = "View Details";
//bind the DataDrid
workorderGrid.D ataSource =
CreateWorkorder DataSource();
workorderGrid.D ataBind();
return workorderGrid;
}
public void Grid_ItemComman d (Object
sender, DataGridCommand EventArgs e)
{
if ( e.CommandName == "Details" )
{
string targetPage
= "workorderDetai lsForm.aspx?Wor korder=" + e.Item.Cells
[0].Text;
Response.Redire ct(
targetPage, true );
}
}
}
}
-----Original Message-----
HI Dave,
That will be a good idea
Cheers,
--
Ignacio Machin,
ignacio.mach in AT dot.state.fl.us
Florida Department Of Transportation
"Dave Bailey" <an*******@disc ussions.microso ft.com> wrote
in messagenews:02******* *************** ******@phx.gbl. .. When I click on the LinkButton the DataGrid disappears
and the page does not move. It is the same page with the
DataGrid gone. Any thoughts? I can send all teh code
on Monday when I get back to work if that helps.
Thanks,
Dave
>-----Original Message-----
>Hi Dave,
>
>Well that code should works fine, what show the address
bar of the browser? >does it stay in the same page?
>Maybe if you post an example with the result of
targetPage and the current >request ( Page.Request.Ra wUrl ) we can see where is the
problem. >
>Cheers,
>
>--
>Ignacio Machin,
>ignacio.mach in AT dot.state.fl.us
>Florida Department Of Transportation
>
>"Dave bailey" <an*******@disc ussions.microso ft.com>
wrote in message >news:09******* *************** ******@phx.gbl. ..
>> When I execute the following code when using a
dynamicall >> created LinkButton in a dynamically created dataGrid,
the >> DataGrid disappears and the page I am trying to get
to >> does not load. Can anyone see what is wrong here?
>>
>> protected void Grid_ItemComman d (Object sender,
>> DataGridCommand EventArgs e)
>> {
>> if ( e.CommandName == "Details" )
>> {
>> string targetPage
>> = "workorderDetai lsForm.aspx?Wor korder=" +
e.Item.Cells >> [0].Text;
>> Response.Redire ct (
>> targetPage, true );
>> }
>> }
>>
>> Thanks,
>>
>> Dave
>
>
>.
>
.