473,387 Members | 1,549 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,387 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 3304
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.