Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 29th, 2006, 05:42 PM
su su is offline
Authorized User
 
Join Date: Nov 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default DropDownList into DataGrid-Every Row has a DDL

Hi,
I have a web form. I am using sql dataadapter, dataset and datagrid for displaying the data. (C#) In first column of all the rows, I have dropdown list that I want to populate on the fly. (so, number of dropdown lists = number of rows) Some of the options in the drop down list are common (e.g.: "View the Order", "Open the Order", "Print the Order" etc.) where as some of the options are specific to the Order Number (e.g.: "Order ######" etc.). Order # is the next column in the datagrid. So, I want to basically capture this Order # and put it as an available option in the dropdown list of the current row. (there is a unique Order # for every row and that # must be the option in the drop down list). How do we do this?

I have written common options in the html section, but I need the Order # which are generated on the fly based on the main SQL statement.Each DDL will be having different Order #.

<asp:DataGrid ID="mygrid2" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="Black" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" OnItemDataBound="mygrid2_ItemDataBound">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="ddlnestedmygrid2" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlst_Handler">
<asp:ListItem Value="1">View Order</asp:ListItem>
<asp:ListItem Value="2">Print Order</asp:ListItem>
<asp:ListItem Value="3">Copy Order</asp:ListItem>
<asp:ListItem Value="0">============</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="OSP_OrderNum" HeaderText="Order #"></asp:BoundColumn>
<asp:BoundColumn DataField="ORD_DateIn" HeaderText="Order Date" DataFormatString="{0:MM/dd/yyyy}" ></asp:BoundColumn>
<asp:BoundColumn DataField="OSP_FSD" HeaderText="ETD Date" DataFormatString ="{0:MM/dd/yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="CustomerNameLong" HeaderText="Customer"></asp:BoundColumn>
<asp:BoundColumn DataField="ccdCustomerName" HeaderText="Customer Of Customer"></asp:BoundColumn>
<asp:BoundColumn DataField="ORD_ShoeName" HeaderText="**************** Name"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Cust PO/Stk#">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "OSP_CustomerPO") + "/" + DataBinder.Eval(Container.DataItem, "OSP_CustomerStk")%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="OSP_ActualQty" HeaderText="Qty"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Approval Sales/OPD">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "ORD_StatusUSASales") + "/" + DataBinder.Eval(Container.DataItem, "ORD_StatusUSAOPD")%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="ORD_Split" HeaderText="Split"></asp:BoundColumn>
</Columns>

</asp:DataGrid>
 
Old November 30th, 2006, 07:30 AM
Authorized User
 
Join Date: Sep 2006
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi , In Databound event of datagrid u can get the value of cell from event args.Which in ur case its cell[0].After getting the value ,u may use it for what ever purpose .
Good Luck

 
Old November 30th, 2006, 10:23 AM
su su is offline
Authorized User
 
Join Date: Nov 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi SriRamaKrishna,

Thanks for replying.

As u suggested cell[0], I think it refers to the column '0' i.e all rows of column '0' - cell [0].

In my case I want to add different values in all DDL. It should be same as the result of cell [1]. - column '1' (order#). And result of order# comes from the database based on the sql criteria.

Please guide me. I will be really thankful to you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how can selectedvalue of DDL make other DDL visibl hertendreef ASP.NET 2.0 Professional 4 May 20th, 2008 04:38 PM
SelectedIndexChanged DDL-->in Datagrid slaverymorgue ASP.NET 2.0 Basics 1 February 19th, 2007 09:30 AM
DropDownList into DataGrid-Every Row has a DDL su ASP.NET 1.0 and 1.1 Basics 0 November 29th, 2006 05:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.