Globemaster
asked on
Requesting Datagrid.Items.Count???
Hello,
i have an ASPX page which submits all of its contents to another ASPX page so they can be insert into an SQL database.
I am trying to get the Datagrid.Items.Count throug Request.Form(Datagrid.Item s.Count) but it doesn't seem to work.
Any suggestions??
Thank you.
i have an ASPX page which submits all of its contents to another ASPX page so they can be insert into an SQL database.
I am trying to get the Datagrid.Items.Count throug Request.Form(Datagrid.Item
Any suggestions??
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can I see your code pls
ASKER
This is the first Page where i define the Datagrid and populate the data from the SQL server to the DataGrid.
<TD align="center" colSpan="4"><asp:datagrid id="DataGrid2" runat="server" Width="100%" Font-Names="Tahoma" Font-Size="XX-Small" EnableViewState="True" CellPadding="4" HeaderStyle-BackColor="Bla ck" HeaderStyle-ForeColor="Whi te" HeaderStyle-HorizontalAlig n="Center" HeaderStyle-Font-Bold="Tru e" OnDeleteCommand="DataGrid2 _Delete" OnUpdateCommand="DataGrid2 _Update" OnCancelCommand="DataGrid2 _Cancel" AutoGenerateColumns="False ">
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="White" BackColor="Black"></Header Style>
<Columns>
<asp:BoundColumn DataField="PartnerID" HeaderText="PartnerID" ReadOnly="True"></asp:Boun dColumn>
<asp:BoundColumn DataField="Name" HeaderText="Name"></asp:Bo undColumn>
<asp:BoundColumn DataField="Country" HeaderText="Country"></asp :BoundColu mn>
</Columns>
</asp:datagrid></TD>
This is the code-behind of the first page:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then show()
End Sub
Private Sub show()
'Dim da As New SqlDataAdapter
Dim conn As New SqlConnection(Application( "SQL_CONNE CTION_STRI NG"))
Dim cmd As New SqlCommand("Select * from External_Partners", conn)
Dim objDR As SqlDataReader
conn.Open()
objDR = cmd.ExecuteReader()
Datagrid2.DataSource = objDR
DataGrid2.DataBind()
conn.Close()
End Sub
Now this is the 2nd page (VB code) in which i wish to get the Datagrid.Items.count
Dim cmdProj_Part As New SqlCommand("Insert into Proj_ExtPartner (ProjectID,PartnerID) values (@ProjectID,@PartnerID) ", conn)
cmdProj_Part.Parameters.Ad d("@Projec tID", SqlDbType.Int)
cmdProj_Part.Parameters.Ad d("@Partne rID", SqlDbType.Int)
Dim i As Integer
Label1.Text = Context.Items("retID")
For i = 0 To Request.Form("DataGrid2.It ems.Count" ) - 1
cmdProj_Part.Parameters("@ ProjectID" ).Value = retProjectID
cmdProj_Part.Parameters("@ PartnerID" ).Value = Request.Form("DataGrid2.It ems(i).Cel ls(1).Text ")
conn.Open()
cmdProj_Part.ExecuteNonQue ry()
conn.Close()
Next
Basically i am trying to get each dataGrid row ID so i can enter it a SQL table.
<TD align="center" colSpan="4"><asp:datagrid id="DataGrid2" runat="server" Width="100%" Font-Names="Tahoma" Font-Size="XX-Small" EnableViewState="True" CellPadding="4" HeaderStyle-BackColor="Bla
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="White" BackColor="Black"></Header
<Columns>
<asp:BoundColumn DataField="PartnerID" HeaderText="PartnerID" ReadOnly="True"></asp:Boun
<asp:BoundColumn DataField="Name" HeaderText="Name"></asp:Bo
<asp:BoundColumn DataField="Country" HeaderText="Country"></asp
</Columns>
</asp:datagrid></TD>
This is the code-behind of the first page:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then show()
End Sub
Private Sub show()
'Dim da As New SqlDataAdapter
Dim conn As New SqlConnection(Application(
Dim cmd As New SqlCommand("Select * from External_Partners", conn)
Dim objDR As SqlDataReader
conn.Open()
objDR = cmd.ExecuteReader()
Datagrid2.DataSource = objDR
DataGrid2.DataBind()
conn.Close()
End Sub
Now this is the 2nd page (VB code) in which i wish to get the Datagrid.Items.count
Dim cmdProj_Part As New SqlCommand("Insert into Proj_ExtPartner (ProjectID,PartnerID) values (@ProjectID,@PartnerID) ", conn)
cmdProj_Part.Parameters.Ad
cmdProj_Part.Parameters.Ad
Dim i As Integer
Label1.Text = Context.Items("retID")
For i = 0 To Request.Form("DataGrid2.It
cmdProj_Part.Parameters("@
cmdProj_Part.Parameters("@
conn.Open()
cmdProj_Part.ExecuteNonQue
conn.Close()
Next
Basically i am trying to get each dataGrid row ID so i can enter it a SQL table.
ASKER