Access to a DataGrid in MultiPage from cs

  • Thread starter Thread starter T.H.M
  • Start date Start date
T

T.H.M

Hello
I have a web form with MultiPage that contain DataGrid
My HTML code in the aspx page:
<iewc:multipage id="MP1" style="Z-INDEX: 101; LEFT: 225px;
POSITION: . . ."/>
iewc:PageView id="processData1/">
asp:DataGrid id="DG2" style="Z-INDEX: 110; LEFT: 699px;
POSITION: absolute; TOP: 379px" unat="server">
</asp:DataGrid<
</iewc:PageView>
</iewc:multipage>
In the full HTML code I have more then one PageVive and
more then one DataGrid.
In my C# code I'm trying to fill the DataGrid in data from
the DB.

The C# code:
SqlConnection conn = new SqlConnection(. . .);
SqlCommand query = new SqlCommand("");
query = new SqlCommand("select . . .",conn);
conn.Open();
SqlDataReader dr;
dr = query.ExecuteReader();
DG2.DataSource = dr; א Error DG2 not recognize
DG2.DataBind(); א Error DG2 not recognize
dr.Close();
conn.Close();

How can I have access to the DataGrid that is defined in
the HTML from the cs file?
Thank you very much!!!
 
Hi
May be there is more to the problem that wasn't clear , I see that you do
access the datagrid already
When you create such object in the html , an object with the ID , in your
case DG2 , would be created in your page class. Thy the this keyword
inside your c# code then the dot operator you would find the datagrid
object with the name DG2 ( however , you posted code already shows that
you are using that ) . if you are using multiple dataGrid , then you would
have as many in your cs file all match the IDs in the HTML
Hope that helps
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
hi there,

the problem might be in
asp:DataGrid id="DG2" style="Z-INDEX: 110; LEFT: 699px;
POSITION: absolute; TOP: 379px" unat="server">

you have there unat="server"
it should be runat

hope this helps you
 
Back
Top