473,666 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Images in datagrid!

Hi guys,
Could some one help me out? I have a datagrid where one Row is for
selecting from radiobuttonlist of too, one has to be chosen. When it's
chosen it is stored in the database and appears to the datagrid after
the insert button pressed. But now I have two images that are supposed
to correspond each of the radiobutton. I made them visible="false" but
I want when one selects one radiobutton the corresponding image
appears along: Visible="True". How could I go about this?
Thank you

Mar 9 '07 #1
4 1970

Presuming you are asking about client-side javascript dynamic change
of image in DataGrid (or GridView).

In ItemDataBound (or RowDataBound) event you need to find image (or
some it's container) by e.Item.FindCont rol (or e.Row.FindContr ol) and
then pass it's ClientID in javascript call of onclick attribute of
associated radio button (which may be found by similar e.Item/
Row.FindControl ).

The onlick attribute may be a javascript function accepting that id
and the sender (this). In that function depending on condition
this.value == true/false you may set
document.getEle mentById(checkB oxID).value = true/false

If client-side dynamicism is not needed or desired, you may trap
OnCheckChanged event alongwith AutoPostBack="t rue". But rather than
dedicated event handler in postback, still set visibility of image in
or after Item/RowDataBound (preferably in).

Mar 9 '07 #2
document.getEle mentById(checkB oxID).value = true/false

oops,,, document.getEle mentById(ImageO rContainerID).s tyle.display =
"block" or "none"
Mar 9 '07 #3
Thanks Yaseen,
I'm getting a little bit lost. When you give me this code how I'm i
supposed to fix it into my code this is the code I'm using for the
radiobutton.
The behind code:

protected void rblmood_Selecte dIndexChanged(o bject
sender,System.E ventArgs e)
{
RadioButtonList rbl = (RadioButtonLis t)sender;
Control parent = rbl.Parent;
while(!(parent is
System.Web.UI.W ebControls.Data GridItem))
{
parent = parent.Parent;
}
}
protected int SetState(object st)
{
string state = st.ToString();
if(state.Equals ("True"))
{
return 0;

}
else
{
return 1;
}
}

Html code is:
<asp:TemplateCo lumn HeaderText="Moo d Today">
<ItemTemplate >
<asp:Image id="imggm" runat="server" Visible="False" ImageUrl="file:///
C:\Inetpub\wwwr oot\DashBoard\M oods\laughing.g if"></asp:Image>
<asp:Image id="imgbm" runat="server" Visible="False" ImageUrl="file:///
C:\Inetpub\wwwr oot\DashBoard\M oods\sad.gif"></asp:Image>
<asp:Label id=Label2 runat="server" text='<%#
DataBinder.Eval (Container,"Dat aItem.MoodToday ")%>'>Label </asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:RadioButto nList id=rblmood runat="server" Width="104px"
AutoPostBack="T rue" SelectedIndex=' <
%#SetState(Data Binder.Eval(Con tainer.DataItem ,"MoodToday"))% >'
Height="40px">
<asp:ListItem Value="Good Mood">Good Mood</asp:ListItem>
<asp:ListItem Value="Bad Mood">Bad Mood</asp:ListItem>
</asp:RadioButton List>
</EditItemTemplat e>

Thanks.

Mar 9 '07 #4
I have just tried your advice but I get an error:
The type or namespace name 'document' could not be found (are you
missing a using directive or an assembly reference?)
What wrong?

Thanks.

Mar 9 '07 #5

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

Similar topics

0
2102
by: Reb | last post by:
I am using a datagrid within another datagrid. My second datagrid is expand/collapse one. I am facing some error. This is my code. ExpandGrid.aspx <form id="Form1" method="post" runat="server"> <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px"
13
1608
by: moondaddy | last post by:
Happy Holidays All! I want to load a datagrid with images and text (Image, text, image, text, etc...). The data for this datagrid will be coming from sql server and the images are stored as files on the server and not in sql server, however, the name and path of the images are stored with the text in sql server. I don't have a clue on how to load the images into the grid, so can someone please advise on how i can get started with this? ...
9
4601
by: tshad | last post by:
Is there a way to use your own image in place of the automatic one that ASP uses when doing editing in your DataGrid pages? We already have a style of button we are using and would like to be consistant. Thanks, Tom.
9
5053
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ******************************************************************************* <asp:DataGrid visible="False" border=1
2
2848
by: Tim::.. | last post by:
Hi I'm trying to create a little application that shows an image of a user when you mouseover there details in a datagrid. The datagrid is populated from an Active Directory Database and I presume the best way to create the popup is by using a layer with javascript hide and show... I intend to use a database to store the pictures in and the use the users full name to build a relationship between the database with the images and the...
14
1830
by: Brett Sinclair | last post by:
Hello everybody I'm still on the learning curve here...and from what I read, I created inherited datagrid class so I could have icons, combobox...etc in the columns of my datagrid. The grid will be used to populate information coming from a Webservice. (No datasets - No datareaders). So, I do not know see how to use the "datasource".
2
3436
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3 datagrida. I would like to set it so that if value of column 3 in datagrid 1 is < 100 set to red, if = 100 set to green if value of column 3 in datagrid 2 is < 90 set to red, if >= 90 set to green if value of column 3 in datagrid 3is < 80 set to red,...
7
3206
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the column need to be a date picker field. I know things will be easier with ASPX datagrid.
76
2965
by: rcoco | last post by:
Hi all, I'm facing this problem I have images on my website but when I Deploye the website on server the Images are not there I only get the X sign. How can I go about this. Thanks
0
2078
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any help........pls urgent ========================================================= <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
0
8444
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
8869
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...
1
8551
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
7386
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
5664
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
4198
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...
1
2771
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
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
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.