Hi Guys,
I have wrote the following web app, a simple datagrid which submits to .csv Everything is fine apart from the textbox from the template column does not write to the .csv
I want the user to be able to input the quantity they require and this appear on the .csv as well as the other information from the datagrid!
Your help would be greatly appreciated!
Code Below;
asp.
<asp:GridView ID="GridView1" runat="server" DataSourceID="as400"
AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
GridLines="None">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="IMSKU" HeaderText="SKU" />
<asp:BoundField DataField="IMDESC" HeaderText="Description" />
<asp:BoundField DataField="JFFXQT" HeaderText="Required"
ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="Qty">
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Code Behind (c#)
//append to csv file
StreamWriter sw = File.AppendText("e:\\results\\decdiylayout.csv");
//seperate datagrid to comma seperated values
for (int i = 0; i < GridView1.Rows.Count; i++)
{
string strRowVal = "";
for (int j = 0; j < GridView1.Rows.Cells.Count; j++)
{
if (strRowVal == "")
{
strRowVal = DateTime.Now + "," + username[1].Remove(3)+ "," + Layout.Text + "," + GridView1.Rows.Cells[j].Text;
}
else
{
strRowVal = strRowVal + "," + GridView1.Rows.Cells[j].Text;
}
}
sw.WriteLine(strRowVal);
}
sw.Close();
}
I have wrote the following web app, a simple datagrid which submits to .csv Everything is fine apart from the textbox from the template column does not write to the .csv
I want the user to be able to input the quantity they require and this appear on the .csv as well as the other information from the datagrid!
Your help would be greatly appreciated!
Code Below;
asp.
<asp:GridView ID="GridView1" runat="server" DataSourceID="as400"
AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
GridLines="None">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="IMSKU" HeaderText="SKU" />
<asp:BoundField DataField="IMDESC" HeaderText="Description" />
<asp:BoundField DataField="JFFXQT" HeaderText="Required"
ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="Qty">
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Code Behind (c#)
//append to csv file
StreamWriter sw = File.AppendText("e:\\results\\decdiylayout.csv");
//seperate datagrid to comma seperated values
for (int i = 0; i < GridView1.Rows.Count; i++)
{
string strRowVal = "";
for (int j = 0; j < GridView1.Rows.Cells.Count; j++)
{
if (strRowVal == "")
{
strRowVal = DateTime.Now + "," + username[1].Remove(3)+ "," + Layout.Text + "," + GridView1.Rows.Cells[j].Text;
}
else
{
strRowVal = strRowVal + "," + GridView1.Rows.Cells[j].Text;
}
}
sw.WriteLine(strRowVal);
}
sw.Close();
}