473,407 Members | 2,320 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,407 software developers and data experts.

Headers and textboxes in datagrid.



Below is my code, would anybody please figure out why it did not display any thing. The database did not anything in there yet, what it does is the header field. It just shows me the headers only, all the textboxes gone.

I want to have at least 5 rows which contain a textbox in each field. I don't know why, please help me

ALl textboxes gone ....

Thanks
public class gridform : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btsave;
protected System.Web.UI.WebControls.DataGrid datagrid;



private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
LoadData();
UpdateView();

}



}


private void LoadData()
{
string mystrConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("dcpols.mdb");

OleDbConnection conn = new OleDbConnection(mystrConn);

Session["QuestionKey"] = 9;

string mystrCmd1 = "SELECT * FROM tblLightingEntry "; //not for retrieving data, it's just to get the headers for the // datagrids

OleDbDataAdapter da = new OleDbDataAdapter(mystrCmd1, conn);

DataSet ds = new DataSet();
da.Fill(ds, "MyQLookupTable");

Session["MyData"] = ds;

}

private void UpdateView()
{
DataSet ds = (DataSet) Session["MyData"];

//onLoadData();

// Bind the data
datagrid.DataSource = ds.Tables["MyQLookupTable"];

// Display the data
datagrid.DataBind();
}
private ArrayList getHeader()
{
DataSet ds = (DataSet)Session["MyData"];
DataTable dt = ds.Tables["MyQLookupTable"];
ArrayList qKeyList = new ArrayList();

foreach(DataRow dr in dt.Rows)
{
qKeyList.Add(dr["Q_Question"].ToString());
}
return qKeyList;

}
public void goSave(object sender,System.EventArgs e)
{


}

------------------------------------
<form id="Form1" method="post" runat="server">
<asp:datagrid id="datagrid" style="Z-INDEX: 101; LEFT: 32px; POSITION: absolute; TOP: 56px" runat="server"
AutoGenerateColumns="False" CellPadding="4" BackColor="White" BorderWidth="1px" BorderStyle="None"
BorderColor="#CC9966" OnItemCreated="ItemCreated" ShowFooter="True" >
<SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle>
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC"></PagerStyle>
<Columns>
<asp:TemplateColumn HeaderText="# of Fixtures" >
<ItemTemplate>
<asp:TextBox Runat="server"></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:linkbutton runat="server" id="btnNewRow" onclick="AddNewRow" Text="Add new row..." />
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Watt/fix before">
<ItemTemplate>
<asp:TextBox Runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Watt/fix after">
<ItemTemplate>
<asp:TextBox Runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Controller Type w hr/s day">
<ItemTemplate>
<asp:TextBox Runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="hrs/day of timer use">
<ItemTemplate>
<asp:TextBox Runat="server" ID="Textbox1"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
Nov 18 '05 #1
0 1120

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

Similar topics

7
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official...
3
by: sam | last post by:
Hello Group, Havent had luck posting it to microsoft.public.dotnet.framework.aspnet.datagridcontrol group. Excuse me for the cross posting. I have a datagrid which needs to be split into multiple...
1
by: Pavel Gusak | last post by:
Hello. I've found DataGrid built-in edit functionality useless. My DataGrid has 9 columns, and is shown just nice until I press 'Edit' on a row. ASP.NET creates 9 TextBoxes, all the same very big...
5
by: Ben | last post by:
Is there any way to freeze the DataGrid headers so that the headers are always viewable while srolling down? Thanks in advance, Ben!
1
by: mg | last post by:
How can I apply validation for date and currency on the values typed in EditItemTemplate TextBoxes in a DataGrid (C# WebForm)
12
by: Mike | last post by:
I'm calling a component to get my data. The component is returning a dataset. I need to populate text boxes on my aspx page with the data within the datalist. Where can I find an example that...
2
by: nate axtell | last post by:
After binding a DataGrid and a few TextBoxes to the same DataTable in VB ..NET I successfully see the TextBoxes update when I change the selection in the DataGrid. I put DataGrid1.Invalidate() in...
4
by: cooltech77 | last post by:
Hi, I am trying to build the following functionality in the datagrid. I have a lot of columns in the datagrid which are being populated from the database and the user needs to scroll...
3
by: Gidi | last post by:
Hi, I've a dataGrid, and When I click with the mouse on one of it's header the DataGrid_Click event is called. I don't have problem with the event, but strange things happen to the dataGrid...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.