473,757 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:TemplateCo lumn HeaderText="Pay ment Status">
<ItemTemplate >
<asp:DropDownLi st ID="ddlPS" AutoPostBack="T rue" runat="server"
OnSelectedIndex Changed="GetSel ectedIndex">
<asp:ListItem Selected="true" >Awaiting Invoice</asp:ListItem>
<asp:ListItem>I nvoice Received</asp:ListItem>
<asp:ListItem>N o Invoice (make payment)</asp:ListItem>
<asp:ListItem>P repayment made (awating invoice)</asp:ListItem>
</asp:DropDownLis t>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:CheckBox ID="cbPS" Runat="server" AutoPostBack="T rue"
OnCheckedChange d="DisablePS" ></asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>

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 3334
Jos
"buran" <bu***@buran.co m> wrote in message
news:O9******** *****@TK2MSFTNG P09.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:TemplateCo lumn HeaderText="Pay ment Status">
<ItemTemplate >
<asp:DropDownLi st ID="ddlPS" AutoPostBack="T rue" runat="server" OnSelectedIndex Changed="GetSel ectedIndex">
<asp:ListItem Selected="true" >Awaiting Invoice</asp:ListItem> <asp:ListItem>I nvoice Received</asp:ListItem>
<asp:ListItem>N o Invoice (make payment)</asp:ListItem>
<asp:ListItem>P repayment made (awating invoice)</asp:ListItem> </asp:DropDownLis t>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:CheckBox ID="cbPS" Runat="server" AutoPostBack="T rue"
OnCheckedChange d="DisablePS" ></asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>

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.Paren t)

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******** ******@TK2MSFTN GP10.phx.gbl...
"buran" <bu***@buran.co m> wrote in message
news:O9******** *****@TK2MSFTNG P09.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:TemplateCo lumn HeaderText="Pay ment Status">
<ItemTemplate >
<asp:DropDownLi st ID="ddlPS" AutoPostBack="T rue"

runat="server"
OnSelectedIndex Changed="GetSel ectedIndex">
<asp:ListItem Selected="true" >Awaiting

Invoice</asp:ListItem>
<asp:ListItem>I nvoice Received</asp:ListItem>
<asp:ListItem>N o Invoice (make payment)</asp:ListItem>
<asp:ListItem>P repayment made (awating

invoice)</asp:ListItem>
</asp:DropDownLis t>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:CheckBox ID="cbPS" Runat="server" AutoPostBack="T rue"
OnCheckedChange d="DisablePS" ></asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>

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
14518
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 when the checkbox is checked and disable the dorp when checkbox is not checked. thanks.
0
1656
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" oncancelcommand="DataGrid3_Cancel" caption="Pricing Schedules" autogeneratecolumns="False" OnItemDataBound="ItemDataBoundEventHandler"> <alternatingitemstyle cssclass="DataGrid_AlternatingItemStyle" /> <columns> <asp:templatecolumn...
1
4338
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 (watch the layout, some have child controls):
2
491
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 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>
10
2446
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 control in a datagrid? Now I have a Select column but the problem is that the user needs to select more than one record and send them all to print, instead of being one by one like is now with the Select column. Another question, is it possible to...
1
1449
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 check the values in the Autos window e.Items.ItemIndex always returns a 0 so the stored procedure does not know which record to delete. Here is the Datagrid markup: <asp:datagrid id="clubdg" DataKeyField="UserID" runat="server"...
1
1373
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 datagrid_Update function I get an Object reference not set to an instance of an object. I am reakky stuck here and I would appreciate any help from you guys.
3
3461
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 paged. As soon as I turn on paging support, I no longer get events properly for any page except the first. 1) The DataGrid displays the page numbers on the top (and bottom). Whenever I click to go to a specific page number, the DropDownList's...
2
2069
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 a row, I change the textbox (or other control), click Update, but it doesn't save my data. I then did this... In Page_Load, I added code to filter the DataGrid only when it was Not Page.IsPostBack. Then the editing/updating of the DataGrid data...
0
9487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10069
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9884
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9735
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7285
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.