-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Rohit_BD
Message 10 in Discussion

Hello, San4u8,Code snippet for demonstration of manipulating drop-downs in template 
column of datagrid:  Copy the following between the <form></form> tags of the aspx 
page in HTML view.  <asp:datagrid id="dgtest" runat="server" 
autogeneratecolumns="False"> <columns> <asp:boundcolumn DataField="col1" 
HeaderText="ID"></asp:boundcolumn> <asp:templatecolumn> <itemtemplate> 
<asp:dropdownlist ID="ddltest" Runat="server"></asp:dropdownlist> </itemtemplate> 
</asp:templatecolumn> </columns> </asp:datagrid>  Copy the following in the Page_Load 
method in code-behind or between the <script runat="server"></script> tags  private 
void Page_Load(object sender, System.EventArgs e) {     DataTable dt = new 
DataTable();         DataRow dr;     DropDownList ddl;       int i;          //Create 
the datasource for the datagrid        dt.Columns.Add("col1", 
Type.GetType("System.String"));  for(i = 0; i < 5; i++)  {               dr = 
dt.NewRow();               dr[0] = i.ToString();           dt.Rows.Add(dr);        }   
    //bind datasource to the datagrid       dgtest.DataSource = dt;         
dgtest.DataBind();      //manipulate the drop-down list of each row of the datagrid.   
 //this code simply displays the ID as the sole element of the drop-down.        for(i 
= 0; i < dgtest.Items.Count; i++)         {               ddl = 
(DropDownList)dgtest.Items[i].FindControl("ddltest");             if(ddl != null)      
           {                       ddl.Items.Clear();                      
ddl.Items.Add(i.ToString());            }       } }  output: ID �  <no col. name> 
------------------- 0  �  | 0 |v| 1  �  | 1 |v| 2  �  | 2 |v| 3  �  | 3 |v| 4  �  | 4 
|v|

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to