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

New Message on BDOTNET

-----------------------------------------------------------
From: scienty77
Message 5 in Discussion

Hi Ramesh, Here it is. In your webform: <asp:datagrid id="DtgTestGrid" Runat="server" 
AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="IDColumn"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="CmbInGrid" Runat="server" 
OnSelectedIndexChanged="CmbPostBack_Click" AutoPostBack="True"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid> In the code behind [I have done it in vb.net] Step 1 Declare   
Protected WithEvents CmbTest As System.Web.UI.WebControls.DropDownList Step 2 DataBind 
 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Handles MyBase.Load
    'Put user code to initialize the page here     If (Not IsPostBack) Then       
ObjDtGrid.Columns.Add("IDColumn")       ObjDtRow = ObjDtGrid.NewRow
      ObjDtRow(0) = 1
      ObjDtGrid.Rows.Add(ObjDtRow)       ObjDtRow = ObjDtGrid.NewRow
      ObjDtRow(0) = 2
      ObjDtGrid.Rows.Add(ObjDtRow)       ObjDtRow = ObjDtGrid.NewRow
      ObjDtRow(0) = 3
      ObjDtGrid.Rows.Add(ObjDtRow)       ObjDtRow = ObjDtGrid.NewRow
      ObjDtRow(0) = 4
      ObjDtGrid.Rows.Add(ObjDtRow) 
      ObjDtCmb.Columns.Add("CatID")
      ObjDtCmb.Columns.Add("CatName")       ObjDtRow = ObjDtCmb.NewRow
      ObjDtRow(0) = 1
      ObjDtRow(1) = "Category 1"
      ObjDtCmb.Rows.Add(ObjDtRow)       ObjDtRow = ObjDtCmb.NewRow
      ObjDtRow(0) = 2
      ObjDtRow(1) = "Category 2"
      ObjDtCmb.Rows.Add(ObjDtRow)       ObjDtRow = ObjDtCmb.NewRow
      ObjDtRow(0) = 3
      ObjDtRow(1) = "Category 3"
      ObjDtCmb.Rows.Add(ObjDtRow)       ObjDtRow = ObjDtCmb.NewRow
      ObjDtRow(0) = 4
      ObjDtRow(1) = "Category 4"
      ObjDtCmb.Rows.Add(ObjDtRow)       DtgTestGrid.DataSource = ObjDtGrid
      DtgTestGrid.DataBind()
    End If   End Sub   Private Sub DtgTestGrid_ItemDataBound(ByVal sender As Object, 
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles 
DtgTestGrid.ItemDataBound
    Dim ObjCmb As DropDownList
    If e.Item.ItemIndex = -1 Then Exit Sub
    ObjCmb = e.Item.FindControl("CmbInGrid")
    ObjCmb.DataSource = ObjDtCmb
    ObjCmb.DataTextField = "CatName"
    ObjCmb.DataValueField = "CatID"
    ObjCmb.DataBind()
  End Sub Step 3 adding event handler
  Protected Sub CmbPostBack_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles CmbTest.SelectedIndexChanged
    Response.Write(sender.id)
  End Sub     Now here you will get it posted back. Now the tricky part: Which you 
have to do Concentrate on Step 2 how you can make which combo has been clicked in the 
datagrid.    Cheers Scorp <COLUMNS><ITEMTEMPLATE></ITEMTEMPLATE></COLUMNS>

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

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_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