datagrid - dropdownlist - checkbox problem

Discussion in 'ASP .Net Datagrid Control' started by buran, Apr 17, 2004.

  1. buran

    buran Guest

    Dear ASP.NET Programmers,

    I have the following problem. I have a datagrid (ID: grdAllActions). This
    datagrid has two template columns: one column with the dropdownlist control
    (ID: ddlPS) and another with a checkbox control (ID: cbPS). My goal is to
    enable or disable the dropdownlist control when the user checks or unchecks
    the checkbox. I am trying the following code:

    <asp:TemplateColumn HeaderText="Payment Status">
    <ItemTemplate>
    <asp:DropDownList ID="ddlPS" AutoPostBack="True" runat="server"
    OnSelectedIndexChanged="GetSelectedIndex">
    <asp:ListItem Selected="true">Awaiting Invoice</asp:ListItem>
    <asp:ListItem>Invoice Received</asp:ListItem>
    <asp:ListItem>No Invoice (make payment)</asp:ListItem>
    <asp:ListItem>Prepayment made (awating invoice)</asp:ListItem>
    </asp:DropDownList>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:CheckBox ID="cbPS" Runat="server" AutoPostBack="True"
    OnCheckedChanged="DisablePS"></asp:CheckBox>
    </ItemTemplate>
    </asp:TemplateColumn>

    Sub DisablePS(ByVal sender As Object, ByVal e As EventArgs)
    Dim cb As CheckBox
    cb = CType(sender, CheckBox)
    If cb.Checked = True Then
    '?????????
    End If
    End Sub

    How can I get the index of the row that contins the checkbox? Thanks in
    advance,

    Burak Kadirbeyoglu
    buran, Apr 17, 2004
    #1
    1. Advertising

  2. buran

    Jos Guest

    "buran" <> wrote in message
    news:...
    > Dear ASP.NET Programmers,
    >
    > I have the following problem. I have a datagrid (ID: grdAllActions). This
    > datagrid has two template columns: one column with the dropdownlist

    control
    > (ID: ddlPS) and another with a checkbox control (ID: cbPS). My goal is to
    > enable or disable the dropdownlist control when the user checks or

    unchecks
    > the checkbox. I am trying the following code:
    >
    > <asp:TemplateColumn HeaderText="Payment Status">
    > <ItemTemplate>
    > <asp:DropDownList ID="ddlPS" AutoPostBack="True"

    runat="server"
    > OnSelectedIndexChanged="GetSelectedIndex">
    > <asp:ListItem Selected="true">Awaiting

    Invoice</asp:ListItem>
    > <asp:ListItem>Invoice Received</asp:ListItem>
    > <asp:ListItem>No Invoice (make payment)</asp:ListItem>
    > <asp:ListItem>Prepayment made (awating

    invoice)</asp:ListItem>
    > </asp:DropDownList>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:CheckBox ID="cbPS" Runat="server" AutoPostBack="True"
    > OnCheckedChanged="DisablePS"></asp:CheckBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > Sub DisablePS(ByVal sender As Object, ByVal e As EventArgs)
    > Dim cb As CheckBox
    > cb = CType(sender, CheckBox)
    > If cb.Checked = True Then
    > '?????????
    > End If
    > End Sub
    >
    > How can I get the index of the row that contins the checkbox? Thanks in
    > advance,
    >
    > Burak Kadirbeyoglu


    Something like:

    Dim item As DataGridItem = CType(cb.Parent,DataGridItem)
    Dim row As Integer = item.ItemIndex

    --

    Jos
    Jos, Apr 17, 2004
    #2
    1. Advertising

  3. buran

    buran Guest

    Thanks Jos,

    That was exactly what I've been looking for (The only change is: cb.Parent
    to cb.Parent.Parent)

    Dim item As DataGridItem = CType(cb.Parent.Parent, DataGridItem)
    Dim row As Integer = item.ItemIndex

    Burak Kadirbeyoglu

    "Jos" <> wrote in message
    news:...
    > "buran" <> wrote in message
    > news:...
    > > Dear ASP.NET Programmers,
    > >
    > > I have the following problem. I have a datagrid (ID: grdAllActions).

    This
    > > datagrid has two template columns: one column with the dropdownlist

    > control
    > > (ID: ddlPS) and another with a checkbox control (ID: cbPS). My goal is

    to
    > > enable or disable the dropdownlist control when the user checks or

    > unchecks
    > > the checkbox. I am trying the following code:
    > >
    > > <asp:TemplateColumn HeaderText="Payment Status">
    > > <ItemTemplate>
    > > <asp:DropDownList ID="ddlPS" AutoPostBack="True"

    > runat="server"
    > > OnSelectedIndexChanged="GetSelectedIndex">
    > > <asp:ListItem Selected="true">Awaiting

    > Invoice</asp:ListItem>
    > > <asp:ListItem>Invoice Received</asp:ListItem>
    > > <asp:ListItem>No Invoice (make payment)</asp:ListItem>
    > > <asp:ListItem>Prepayment made (awating

    > invoice)</asp:ListItem>
    > > </asp:DropDownList>
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > > <asp:TemplateColumn>
    > > <ItemTemplate>
    > > <asp:CheckBox ID="cbPS" Runat="server" AutoPostBack="True"
    > > OnCheckedChanged="DisablePS"></asp:CheckBox>
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > >
    > > Sub DisablePS(ByVal sender As Object, ByVal e As EventArgs)
    > > Dim cb As CheckBox
    > > cb = CType(sender, CheckBox)
    > > If cb.Checked = True Then
    > > '?????????
    > > End If
    > > End Sub
    > >
    > > How can I get the index of the row that contins the checkbox? Thanks in
    > > advance,
    > >
    > > Burak Kadirbeyoglu

    >
    > Something like:
    >
    > Dim item As DataGridItem = CType(cb.Parent,DataGridItem)
    > Dim row As Integer = item.ItemIndex
    >
    > --
    >
    > Jos
    >
    >
    buran, Apr 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. buran
    Replies:
    2
    Views:
    2,237
    buran
    Apr 17, 2004
  2. tshad
    Replies:
    0
    Views:
    514
    tshad
    Apr 15, 2005
  3. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    809
    David Wier
    Oct 6, 2006
  4. Joey Pang
    Replies:
    4
    Views:
    510
    Joey Pang
    Jun 13, 2005
  5. shiv

    Problem with DataGrid, CheckBox and DropDownList

    shiv, Jun 17, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    155
Loading...

Share This Page