473,804 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read Value from DropDownList in TemplateColumn?

I am fairly new to ASP.NET, so bear with me...

I have a Datagrid with a data-bound DropDownList in the TemplateColumn. Here
is the HTML code:

<asp:TemplateCo lumn HeaderText="Voi d">
<ItemStyle horizontalalign ="Left" wrap="False"></ItemStyle>
<ItemTemplate >
<%#Databinder.E val(Container.D ataItem, "isVoid")%>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st ID="ddlIsVoid" Runat="server"
CssClass="ddl10 0"></asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>

In Edit Mode, the end-user can select either True or False in the
DropDownList, then save those changes. ALL of that is working correctly.

The trouble comes when I try to deal with the value of that Datagrid column
directly. It appears to always equate to String.Empty. Everytime the
Datagrid is displayed, I go through the rows and change the Row forecolor to
Red where the IsVoid column is True.

Private Sub ColorVoidRows(B yVal dg As DataGrid, ByVal vindex As Integer)

For Each item As DataGridItem In dg.Items
If item.Cells(vind ex).Text = "True" Then
item.ForeColor = Color.Red
End If
Next
End Sub

This method works on a number of other Datagrid that can be displayed on the
page, but those Datagrids don't have the templated IsVoid column. So, I
figure it must have something to do with that.

The Cells index is working and I have confirmed that I am looking at the
correct column.

My question is how do I retrieve that value from that TemplateColumn when I
am NOT in Edit Mode?

Any help is greatly appreciated.

carl
Jun 8 '06 #1
0 1176

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

Similar topics

5
10590
by: Ronald S. Cook | last post by:
In my ASP.NET DataGrid, I would like to set the "Selected" value of a dropdown list item depending on a condition. While this is easy to do for, say, a textbox, .NET doesn't seem to play as nice in a dropdownlist. In the below I get the error Compiler Error Message: CS0117: 'System.Web.UI.WebControls.ListItem' does not contain a definition for 'DataBinding' <asp:TemplateColumn HeaderText="Ver"> <HeaderStyle HorizontalAlign="Center"...
4
3255
by: Carlo Marchesoni | last post by:
I have an editable Datagrid and some columns (4 and 5) are TemplateColumns (because I have DropDownLists there). Everything works fine except that if I want to retrieve the values (that I can see visually) from the DataGrid with the following loop the Values of the TemplateColumns are returned as blank - what am I doing wrong ?: foreach (DataGridItem dgi in dgrDu01.Items) { string myvalue1 = dgi.Cells.Text; //ok etc.. string myvalue =...
2
2024
by: jason | last post by:
Pardon my ignorance on this. The below code works, except, when I edit a record and update the two drop downs take the first entry in the dropdownlist if not selected. I'd also like the dropdown to show the current value in edit mode. I'm sure this is a common question. I've reviewed several related post and tried them out to no avial. Some of the offerings in listgroup look right on, but are not clear on where to handle the suggested...
6
5398
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I am receiving errors when trying to set the selected value of the dropdown within the ItemDataBound() subroutine. Below is the code I am using. I hope someone can tell me if this is possible. '''HTML''' <asp:datagrid id="dgAssignments"...
2
2352
by: Luis Esteban Valencia | last post by:
Hello I have a datagrid with a dropdownlist that has the products, another column has the price of the product and when the user changes the product it also must change the price how can I achieve that. Thanks Datagrid html
0
1538
by: Luis Esteban Valencia | last post by:
Hello. I have a datagrid with one row. I have a button that adds a new row. I am trying to implement that when the user selects one product it must change the price on the quantity column. Anyway when the user selects the first dropdownlist the dropdownselected_indexchanged is firring but when the user chagnes the second dropdownlist its not firing. aahh! if the user selects any of both dropdownlist the datagrid stays with only one row?...
0
1858
by: rmccinc | last post by:
I have a dropdownlist in a datagrid and it has autopostback set to true. I need to get the new value of that dropdown to fill a textbox in the same datagrid row. I have set the databind event on the gridview to fire on pageload (including postbacks) because I need to change the value of the textbox at each of the dropdownlists autopostback event. I am using the OnItemDataBound event of the gridview to grab the selectedvalue of the...
0
2169
by: weiwei | last post by:
Hi here is my scenario, I create a drop down list in itemtemplate.(that drop down is created from db), after user click edit command, my ideal plan is have another drop down list in edititemtemplate with preselected value from the previous drop down list, so far I can only achieved with the regular drop down list in edititemtemplate with no preselected value from previous one. anyone can help me. thanks in advance. below is my current...
2
7322
by: Steve Hershoff | last post by:
Hi everyone, I have a DataGrid with several TemplateColumns. One of these columns has an EditItemTemplate that contains an ASP.Net DropDownList. I'm catching this DropDownList's SelectedIndexChanged event. I also have another TemplateColumn, with a RequiredFieldValidator that validates a TextBox in the column. It all looks like this, in broad strokes:
0
9714
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
10346
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
10347
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
10090
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...
0
9173
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
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
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.