473,324 Members | 2,356 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,324 software developers and data experts.

how to select blank value in ddl when datagrid goes to editmode

All is working well for my dropdown/datagrid except I cannot figure out
how to set my ddl selected index when the value is blank/null.
ie before edit mode the lblVariation text value is blank..

This routine sets the value strVariation

Sub dgMinimumWage_EditRow(sender as Object, e As
DataGridCommandEventArgs)
strVariation = CType(E.Item.FindControl("lblVariation"), Label).Text
dgMinimumWage.EditItemIndex = e.Item.ItemIndex
dgMinimumWageBindData()
End Sub

This routine works great when I've got a value.

Public Sub SetVariationDropDownIndex(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim ed As System.Web.UI.WebControls.DropDownList
ed = sender
If strVariation Is "" THEN
ed.SelectedIndex = 0
Else
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByText(strVariation) )
End If
End Sub
On the html side I have this..

<asp:TemplateColumn HeaderText="Variation/Condition">
<itemtemplate>
<asp:label ID="lblVariation" Text='<%#
DataBinder.Eval(Container.DataItem, "english_text") %>' Runat="server"
/>
</ItemTemplate>

<edititemtemplate>
<asp:dropdownlist id="ddlVariations" runat="server"
DataTextField="english_text" DataValueField="minimum_wage_variation_id"
DataSource="<%# GetVariations() %>"
OnPreRender="SetVariationDropDownIndex" Width="450">
<asp:listitem Value="0">dave</asp:listitem>
</asp:dropdownlist>

</EditItemTemplate>
</asp:TemplateColumn>

However the selected value in the dropdown is always the first
variation in the datset..

Am I able to do this at runtime or maybe I should try and add a blank
value to the dataset??

Any suggestions??

Dave

Nov 19 '05 #1
2 1618
Add a Databinding for your SelectedValue

e.g. SelectedValue='<%# String.Empty %>'

<dr****@canoemail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
All is working well for my dropdown/datagrid except I cannot figure out
how to set my ddl selected index when the value is blank/null.
ie before edit mode the lblVariation text value is blank..

This routine sets the value strVariation

Sub dgMinimumWage_EditRow(sender as Object, e As
DataGridCommandEventArgs)
strVariation = CType(E.Item.FindControl("lblVariation"), Label).Text
dgMinimumWage.EditItemIndex = e.Item.ItemIndex
dgMinimumWageBindData()
End Sub

This routine works great when I've got a value.

Public Sub SetVariationDropDownIndex(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim ed As System.Web.UI.WebControls.DropDownList
ed = sender
If strVariation Is "" THEN
ed.SelectedIndex = 0
Else
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByText(strVariation) )
End If
End Sub
On the html side I have this..

<asp:TemplateColumn HeaderText="Variation/Condition">
<itemtemplate>
<asp:label ID="lblVariation" Text='<%#
DataBinder.Eval(Container.DataItem, "english_text") %>' Runat="server"
/>
</ItemTemplate>

<edititemtemplate>
<asp:dropdownlist id="ddlVariations" runat="server"
DataTextField="english_text" DataValueField="minimum_wage_variation_id"
DataSource="<%# GetVariations() %>"
OnPreRender="SetVariationDropDownIndex" Width="450">
<asp:listitem Value="0">dave</asp:listitem>
</asp:dropdownlist>

</EditItemTemplate>
</asp:TemplateColumn>

However the selected value in the dropdown is always the first
variation in the datset..

Am I able to do this at runtime or maybe I should try and add a blank
value to the dataset??

Any suggestions??

Dave

Nov 19 '05 #2
tx for the reply David but using that gives me:
Specified argument was out of the range of valid values

Nov 19 '05 #3

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

Similar topics

2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
2
by: Amir | last post by:
I really hope someone can explain this behavior. I have spend quite a bit of time and tried a bunch of things, so far nothing has worked. I have a page on which I have a datagrid with template...
0
by: bob | last post by:
I'm using the DataGridView control, with EditMode set to "edit programatically" and SelectionMode set to "FullRowSelect" (or something like that). My program allows the User to go into edit mode by...
0
by: Amit | last post by:
Hi Team, code to select the datagridview row when its EditMode property is set to EditOnEnter. Thanks, Amit amit.srivastava77@gmail.com, amit.srivastava@india.rsystems.com
1
by: Amit | last post by:
Hi, Can anyone give me the solution of selecting an entire row when datagridview editmode property is set to EditOnEnter. Thanks, Amit
0
by: Jayant Solanki | last post by:
i have a problem with edit mode in datagrid. i have a calculation field in datagrid in which i want to do auto caluclation of "Total Fees" after updating the Amount and Rate. so how can i use...
0
by: Luqman | last post by:
Which event of Datagrid is fired when i click on a Datagrid New Row. I want to add a LineNo Value to its cell no. 5 ? I tried UserAddedRows Event but its not working ? How can I know, if the...
0
by: yzlin04 | last post by:
I have a datagrid in my program with the dataset is dsTempTransaction. I want to select one row from that datagrid and then when i press a select button, the value i have selected will be copied into...
1
by: Ky_fanatic | last post by:
I am working on an application which returns data from multiple databases. The user enters a pallet ticket and it goes out to the multiple db's and returns data which meets the criteria. My...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.