i need an order screen in C# asp.net. i googled a loat but can't find any method to do that.
please check that picture
http://i.stack.imgur.com/omni6.png[
^]
i want to do like this Checkedboxlist have all items when ever user select an item it should add in gridview.when uncheck it should remove from gridview.
C# Code
protected void Page_Load(object sender, EventArgs e)
{
BALL data = new BALL();
DataSet ds = data.NewOrderLoad();
GridView1.DataSource = new System.Collections.ArrayList();
GridView1.DataBind();
items = new DataTable();
items = ds.Tables[0];
if (!IsPostBack)
{
for (int i = 0; i < items.Rows.Count; i++)
{
ListItem li = new ListItem(items.Rows[i][1].ToString(),
items.Rows[i][0].ToString());
CheckBoxList1.Items.Add(li);
}
}
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(string));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("UnitPrice", typeof(string));
dt.Columns.Add("Price", typeof(string));
dt.Columns.Add("Quantity", typeof(string));
string Id = Selected data;
string Name = Selected data;
string UnitPrice = Selected data;
string Price = Selected data;
string Quantity =Selected data;
dt.Rows.Add(Id , Name, UnitPrice, Price, Quantity);
GridView1.DataSource = dt;
GridView1.DataBind();
}
gridview can't maintain view state
help me to make complete order screen start to end.
Please Help me that is my college project.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" MaintainScrollPositionOnPostback="true" CellPadding="4" ForeColor="#333333" GridLines="None" ShowHeader="True" ShowHeaderWhenEmpty="True" ViewStateMode="Disabled">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ItemStyle-Width="30" HeaderStyle-Width ="30"/>
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="250" HeaderStyle-Width ="250"/>
<asp:BoundField DataField="UnitPrice" HeaderText="Unit Price" ItemStyle-Width="75" HeaderStyle-Width ="75" />
<asp:BoundField DataField="Price" HeaderText="Price" ItemStyle-Width="75" HeaderStyle-Width ="75" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" ItemStyle-Width="75" HeaderStyle-Width ="75"/>
</Columns>
</asp:GridView>