473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

datagrid - dropdownlist - checkbox problem

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
Nov 18 '05 #1
2 3305
Jos
"buran" <bu***@buran.com> wrote in message
news:O9*************@TK2MSFTNGP09.phx.gbl...
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
Nov 18 '05 #2
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" <jo***************@fastmail.fm> wrote in message
news:O8**************@TK2MSFTNGP10.phx.gbl...
"buran" <bu***@buran.com> wrote in message
news:O9*************@TK2MSFTNGP09.phx.gbl...
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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rodrigo guerra | last post by:
i have a checkbox and a dropdownlist in 2 templatecolumns in a datagrid. how can i add a onClick/CheckedChanged event handler to a checkbox in the datagrid ? i want to enable a dropdownlist...
0
by: shamila | last post by:
</asp:label><asp:datagrid id="DataGrid3" runat="server" cssclass="DataGrid" showfooter="True" onupdatecommand="DataGrid3_Update"ondeletecommand="DataGrid3_Delete" oneditcommand="DataGrid3_Edit"...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
2
by: buran | last post by:
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...
10
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox...
1
by: I am Sam | last post by:
I need to be able to delete a record/row from a database table. I am using a DataGrid which is not sending the row index key properly to the event in the codebehind. When I set a break point and...
1
by: Michael Kolias | last post by:
Hi everybody, I am having a problem getting the selected value of a drop down list that is populated dynamically inside a datagrid control. When I try to access the selected item on the...
3
by: danc | last post by:
I have a datagrid with a checkbox and dropdown list in each row. Both set AutoPostBack to true and ItemCommand and OnSelectedIndexChanged events for these controls works fine when DataGrid is not...
2
by: Gummy | last post by:
Hello All, I have a webpage that has two dropdown listboxes. Based on what is selected in these dropdown listboxes, it filters a DataGrid . That works fine. In the DataGrid , when I go to edit...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.