OK I tried and I can't still manage it.
Here's the full scenario:
What I am building is a footy tipping (pool) competition app. What I am
trying to do is to allow lots of people to tip the winning team from a list
of games to be played every week. This schematic shoulf give an idea of the
tipping form:
Tipping Form
Date Time Home Team Visiting Team Tie
2 Aug, 03 7:00 PM England Fiji
2 Aug, 03 7:00 PM Fiji Australia
2 Aug, 03 7:00 PM New Zealand Australia
This is the datagrid my ASPX Page:
-------------------------------------------------------------------
<asp:datagrid id=DataGrid1 runat="server" Width="100%"
AutoGenerateCol umns="False" DataMember="Tab le" DataKeyField="G ameID"
DataSource="<%# dsMatchesForTip ping1 %>" ForeColor="Blac k" GridLines="None "
CellPadding="2" BackColor="Ligh tGoldenrodYello w" BorderWidth="0p x"
BorderColor="Ta n">
<Columns>
<asp:TemplateCo lumn SortExpression= "GameID">
<ItemTemplate >
<input type="hidden" runat="server" name="GameID" id="GameID" value='<%#
DataBinder.Eval (Container.Data Item, "GameID") %>' />
</ItemTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Date " SortExpression= "Date" HeaderText="Dat e"
DataFormatStrin g="{0:d MMM, yy}" />
<asp:BoundColum n DataField="Time " SortExpression= "Time" HeaderText="Tim e"
DataFormatStrin g="{0:t}" />
<asp:BoundColum n DataField="Home TeamName" SortExpression= "HomeTeamNa me"
HeaderText="Hom e Team" />
<asp:TemplateCo lumn SortExpression= "HomeTeamID ">
<ItemTemplate >
<INPUT id="radioButton PickHomeTeam" runat="server" type="radio" value='<%#
DataBinder.Eval (Container.Data Item, "HomeTeamID ") %>' name="Pick">
</ItemTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Visi tingTeamName"
SortExpression= "VisitingTeamNa me" HeaderText="Vis iting Team" />
<asp:TemplateCo lumn SortExpression= "VisitingTeamID ">
<ItemTemplate >
<INPUT id="radioButton PickVisitingTea m" runat="server" type="radio"
value='<%# DataBinder.Eval (Container.Data Item, "VisitingTeamID ") %>'
name="Pick">
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Tie ">
<ItemTemplate >
<INPUT id="radioButton PickTie" runat="server" type="radio" value="Tie"
name="Pick">
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn SortExpression= "UserEmail" >
<ItemTemplate >
<input type="hidden" runat="server" name="UserEmail " id="UserEmail"
value="ss*@ssp. com" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
----------------------------------------------------------------------------
----
For the Code Behind Page:
----------------------------------------------------------------------------
------
private void Submit1_ServerC lick(object sender, System.EventArg s e)
{
string[,] tippings = new string[,] {{"988", "AUS", "hhhty"}, {"56678",
"SA", "LfghghjLL" }, {"2367673", "NZ", "dfdfghgfjgfhf" }};
for (int i = 0; i <= tippings.Rank; i++) {
oleDbInsertComm and2.Parameters["GameID"].Value = tippings[i, 0];
oleDbInsertComm and2.Parameters["Pick"].Value = tippings[i, 1];
oleDbInsertComm and2.Parameters["Username"].Value = tippings[i, 2];
oleDbConnection 1.Open();
oleDbInsertComm and2.ExecuteNon Query();
oleDbConnection 1.Close();
}
}
----------------------------------------------------------------------------
----------
Basically, if I am able to insert in the database the array "tippings"; then
I should be able to dynamically populate the "tippings" array and then
insert it into the database.
Unfortunately I am unable to do it ;-( and time isn't on my side either.
Any ideas?
SSP
"Mike S" <mi***@n-o.sp-a.m.pac.odedode a.edu> wrote in message
news:uK******** ******@TK2MSFTN GP10.phx.gbl...
I'm not sure if I'm answering the question you are asking, but if you need
to create a dynamic array (to replace the static dummy array "string[,]
tippings") that is pretty simple:
name the all your input fields for each row the same (using a numerical
sequence for each extra row), when you submit, use something like:
// for loop
string[] row = Request.Form[ strPrefix +
iRowName.ToStri ng() ].ToString.Split (", ");
AddRowToDB( row );
//end for loop
It would be a whole lot easier to do this using a DataGrid, DataSet,
DataAdapter, and relative Commands for the DataAdapter.
// Mike