473,587 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issue making textbox visible based on specific input from a radio button list in an EditItemTemplat e

Dan
Issue making textbox visible based on specific input from a radio button
list in an EditItemTemplat e

I want to setup a gridview that when in edit mode and when the user
selects "Other" from a radiolist that a text box will appear and the
user can input text.

I can get the textbox to appear after selecting other in the radiolist;
however, the selected value in the radiolist disappears. I believe this
is due to the databind call.

But I cannot seemd to get the textbox to appear without makeing the
databind call.

Can someone steer me in the right direction?

My sample code:

<asp:GridView DataKeyNames="R eturnId" ID="ListGrid" runat="server"
AutoGenerateCol umns="False"
OnRowEditing="L istGrid_RowEdit ing"
OnRowUpdating=" ListGrid_RowUpd ating"
OnRowCancelingE dit="ListGrid_R owCancelingEdit ">

<Columns>
<asp:BoundFie ld DataField="Retu rnId" HeaderText="Ret urn Id"
ReadOnly="true" />

<asp:TemplateFi eld ShowHeader="Fal se">
<EditItemTempla te>
<asp:LinkButt on ID="UpdateBtn" runat="server"
CausesValidatio n="True" CommandName="Up date"
Text="Update"></asp:LinkButton>
<asp:LinkButt on ID="CancelBtn" runat="server"
CausesValidatio n="False" CommandName="Ca ncel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplat e>
<ItemTemplate >
<asp:LinkButt on ID="EditBtn" runat="server"
CausesValidatio n="False" CommandName="Ed it"
Text="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rea son"
SortExpression= "ReasonForCredi t">
<EditItemTempla te>
<asp:RadioButto nList ID="ddlReason" AutoPostBack="t rue"
runat="server" OnSelectedIndex Changed="ddlRea son_SelectedInd exChanged"
>
<asp:ListItem Text="Other" Value="0" />
<asp:ListItem Text="Too big" Value="2" />
<asp:ListItem Text="Too small" Value="1" />
</asp:RadioButton List>
<asp:TextBox ID="tbOther" Visible='<%# IsOtherTBVisibl e(
Eval("ReasonCod e")) %>' runat="server" />
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="lblReasonCo de" Text='<%#
Eval("ReasonCod e") %>' runat="server" />
</ItemTemplate>
<ItemStyle CssClass="name" />
<HeaderStyle CssClass="name" />
</asp:TemplateFie ld>

</Columns>

</asp:GridView>

code behind

protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}

protected void BindData()
{
if (!IsPostBack || _RefreshData)
{
DataSet ds = SqlTools.OpenDa taSet("SELECT * FROM RETURNS",
ConnString);
DataView dv = ds.Tables[0].DefaultView;

ListGrid.DataSo urce = ds.Tables[0];
SaveDataSetToSe ssion(ds);
_RefreshData = false;
}
else
{
DataView dv = RetrieveSession DataSet().Table s[0].DefaultView;
ListGrid.DataSo urce = RetrieveSession DataSet().Table s[0];
}

ListGrid.DataBi nd();
}

protected void SaveDataSetToSe ssion(DataSet dsToSave)
{
Session.Add("Re turns", dsToSave);
}

protected DataSet RetrieveSession DataSet()
{
return (DataSet)Sessio n["Returns"];
}

protected void ListGrid_RowEdi ting(object sender, GridViewEditEve ntArgs
e)
{
ListGrid.EditIn dex = e.NewEditIndex;
BindData();
}

protected void ListGrid_RowCan celingEdit(obje ct sender,
GridViewCancelE ditEventArgs e)
{
ListGrid.EditIn dex = -1;
BindData();
}

protected void ddlReason_Selec tedIndexChanged (object sender, EventArgs
e)
{
if (((RadioButtonL ist)sender).Sel ectedItem.Value == "0")
{
_tbOtherVisible = true;
}
else
{
_tbOtherVisible = false;
}

BindData();
}

protected bool IsOtherTBVisibl e(object ReasonCode)
{
return _tbOtherVisible ;
}

*** Sent via Developersdex http://www.developersdex.com ***
Nov 30 '06 #1
0 3657

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

Similar topics

9
2963
by: Gary | last post by:
Hello, Is it possible to dynamically update a textbox with words chosen from a list using form checkboxes and javascript? Gary
2
2955
by: Bart Verbeke | last post by:
Hi, I have a form with 2 radio buttons (ACCEPT/REJECT). When the page is initially loaded, no textbox should be visible. When a user clicks the REJECT radio button, a textbox should automatically appear below the radiobutton where the user can motivate why he chose the reject option (which we require). When the user clicks the ACCEPT radio button, the textbox should not
5
1922
by: Girish | last post by:
I have TWO submit buttons of type IMAGE on my asp form. This renders as <input type="image">. I need to be able to eble the ENTER button for both buttons. Yes, I know that for the input type image, the submit happens automatically to the server. Heres my problem: I have two event handlers for both these buttons as stated below: BUTTON 1:
3
4432
by: newjazzharmony | last post by:
Hello group, I want to automatically select a specific checkbox when a user clicks (selects) a specific item in a radiobutton group. Both controls are in the same form. Let's say for argument's sake that the form looks like this (inessential items left out for the sake of clarity): <form name=form1>
11
3554
by: TechnoAtif | last post by:
Here is the other one..This requires a textbox to open while clicking of a radiobutton in one part and in the other part on the click of a list/menu. I want that..as I click the second radiobutton,the textbox be displayed so that the data may be posted.else itremains hidden or engraved..and a similar other problem with list/menu in place of rado button. Tablename:form Columnames :(i) des,des_url Columnnames:(ii)dom,domname <form...
1
1872
by: hotflash | last post by:
Hi Master CroCrew et All, I am working on a CASE statement to allow different type of searches to search for different type of projects. EVERYTHING WORKS FINE EXCEPT, if the "Any Projects" radio button is checked and if the "All, Complete or Incomplete button is checked, it DISPLAYS everything fine. However, if the "Any Projects" radio button is checked and if the "Complete Projects Only" or "Incomplete Projects Only" button is checked IT...
1
1969
by: klaul | last post by:
Hi there. I'm having an issue with autopostback, in that it doesn't seem to be working! The webform I am using pulls the data from an AccessDataSource to populate the gridview, which has Edit and Delete functions. I have also configured it so that I can insert into the gridview using the footer row. What I am now trying to do is create two searchable dropdowns in the header of the first two columns (company and reference) that would just...
2
12869
by: mrutyunjaya | last post by:
hello, i have two textbox column and one button control in gridvie when i click button it will ask plese enter price in first textbox . when enter values it is asking again. how to pass textboxid in javascript .my code is function validation() { alert("hi")
9
1960
by: tvnaidu | last post by:
This is just small plain HTML program wtote manually (since I am new to web programming, may be some tools I can use I think), this program loaded onto microcontroller with small foot print web server, when program prints, half-way it prints, then it struck, any issue with this?. when user clicks "submit" again it loaded same page. but it sends some sytring to server (plug1=ON&......), that string will be processed inside server. any open...
0
7924
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
7854
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8349
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...
0
6629
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
5395
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
3845
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
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
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.