473,378 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

DataGrid Disappears Part 2

I am posting the entire code for this problem in hopes
soneone can see what is wrong and why the page refreshes
and the dataGrid disappears but the new page does not load.

Thanks,

Dave

Code Follows:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.OleDb;

namespace Type3CTracking
{
/// <summary>
/// Summary description for MRDetailsForm.
/// </summary>
public class MRDetailsForm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label
mrLabel;
protected System.Web.UI.WebControls.Panel
Panel1;
protected
System.Web.UI.WebControls.TextBox mrText;
protected DataGrid workorderGrid = new
DataGrid();
protected System.Web.UI.WebControls.Label
workorderLabel;
protected
System.Web.UI.WebControls.PlaceHolder workorderHolder;
protected
System.Data.OleDb.OleDbDataAdapter oda;

private void Page_Load(object sender,
System.EventArgs e)
{
string mr = Request["MR"];
mrText.Text = mr;

if (!IsPostBack)
{

workorderHolder.Controls.Add(MakeWorkorderGrid());
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required
by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new
System.EventHandler(this.Page_Load);

}
#endregion

public DataView CreateWorkorderDataSource()
{
string workorderConnect
= "Provider=\"MSDAORA.1\";User ID=dave;Data
Source=demo;Password=xxxxx";
string workorderSelect = "Select
MR.Mrnum, Mrline.Mrlinenum, Workorder.Wonum,
Workorder.Description from" +
" MR, Mrline, Workorder
where MR.Mrnum = Mrline.Mrnum and Mrline.Wonum =
Workorder.Wonum" +
" and MR.Mrnum = " + "'" +
mrText.Text + "'";

oda = new OleDbDataAdapter
(workorderSelect, workorderConnect);
DataSet ds = new DataSet();

oda.Fill(ds, "workorder");
DataView workorder = ds.Tables
["workorder"].DefaultView;
return workorder;
}

public DataGrid MakeWorkorderGrid()
{
//make the DataGrid

workorderGrid.CellPadding = 2;
workorderGrid.CellSpacing = 0;
workorderGrid.Width = 700;
workorderGrid.BorderWidth = 1;
workorderGrid.BorderColor =
Color.Black;

//turn off autogeneratecolumns
feature
workorderGrid.AutoGenerateColumns
= false;
workorderGrid.ForeColor =
Color.Blue;
workorderGrid.Font.Size = 10;
workorderGrid.Font.Name = "Arial";

//sets the HeaderStyle

workorderGrid.HeaderStyle.BackColor = Color.Gold;

workorderGrid.HeaderStyle.ForeColor = Color.Blue;

workorderGrid.HeaderStyle.Font.Name = "Arial";

workorderGrid.HeaderStyle.Font.Size = 10;

workorderGrid.HeaderStyle.Font.Bold = true;

workorderGrid.HeaderStyle.HorizontalAlign =
HorizontalAlign.Center;

//sets alternating style

workorderGrid.AlternatingItemStyle.BackColor =
Color.Silver;

workorderGrid.AlternatingItemStyle.ForeColor =
Color.Black;

//sets the itemstyle

workorderGrid.ItemStyle.HorizontalAlign =
HorizontalAlign.Center;

//create the bound columns
BoundColumn Wonum = new BoundColumn
();
BoundColumn Mrlinenum = new
BoundColumn();
BoundColumn Desc = new BoundColumn
();
Wonum.HeaderText = "Wonum";
Wonum.DataField = "Wonum";

Mrlinenum.HeaderText = "MR Line
Number";
Mrlinenum.DataField = "Mrlinenum";

Desc.HeaderText = "Description";
Desc.DataField = "Description";

//add bound columns to datagrid
workorderGrid.Columns.AddAt(0,
Wonum);
workorderGrid.Columns
[0].ItemStyle.Width = 20;
workorderGrid.Columns.AddAt(1,
Mrlinenum);
workorderGrid.Columns
[1].ItemStyle.Width = 100;
workorderGrid.Columns.AddAt(2,
Desc);

//add a LinkButton column
ButtonColumn bc = new ButtonColumn
();
bc.ButtonType =
ButtonColumnType.LinkButton;
bc.Text = "Click to View workorder
details";
bc.CommandName = "Details";
workorderGrid.Columns.Add(bc);
workorderGrid.Columns
[3].HeaderText = "View Details";

//bind the DataDrid
workorderGrid.DataSource =
CreateWorkorderDataSource();
workorderGrid.DataBind();
return workorderGrid;
}
public void Grid_ItemCommand (Object
sender, DataGridCommandEventArgs e)
{
if ( e.CommandName == "Details" )
{
string targetPage
= "workorderDetailsForm.aspx?Workorder=" + e.Item.Cells
[0].Text;
Response.Redirect(
targetPage, true );
}
}

}
}

Nov 15 '05 #1
0 1013

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

Similar topics

4
by: Dave bailey | last post by:
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...
8
by: Sue | last post by:
I have a datagrid populated with 6 visible read-only labels and several hidden fields. Below the datagrid, I have a table with various textboxes, dropdowns, etc. I've managed to decypher the...
2
by: Stephan Bour | last post by:
Hi, Ičve tried to implement a solution to populate a dropdownlist inside an editable datagrid. The code is simple enough and an example can be found here:...
0
by: DJ Dev | last post by:
Hi All, I have 2 datagrids which are generated in runtime based on values selected by user from a dropdown. I have a template column in the datagrid with checkboxes. I want the user to select some...
2
by: Deepesh | last post by:
Good day, I have a specific case of the DataGrid in my solution which is causing the ItemCommand Event Not Firing. So I'm creating a "Skinnable" set of controls. I seperate the actual ASCX file...
8
by: Strahimir Antoljak | last post by:
I bound a DataGrid to a table (I tried with a DataView too). I removed the row from the table, and then inserted a new row at the same row index. the table gets the row to the right position, but...
2
by: Bunnist-Priest | last post by:
Hello Everyone, My first predicament is that I want to make a colomn of my vb.net DataGrid a ProgressBar colomn. (full of Pr.Bars). Is it that difficult? Is there a code example? using - Dim...
0
by: news.zen.co.uk | last post by:
Hi Guys, Using VB .NET 2003 and ASP1.1, I have a Datagrid embedded in an ASP page. In the processing of the ItemDataBound event I dynamically create a new Datagrid control within the Cell of the...
2
by: rpdavis | last post by:
I have a datagrid that includes editable colums as well as a hyperlink. When the user selects to edit a row in the datagrid, the text for the hyperlink disappears. When the grid is refreshed...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.