473,508 Members | 2,295 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 1961

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.FindControl (or e.Row.FindControl) 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.getElementById(checkBoxID).value = true/false

If client-side dynamicism is not needed or desired, you may trap
OnCheckChanged event alongwith AutoPostBack="true". 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.getElementById(checkBoxID).value = true/false

oops,,, document.getElementById(ImageOrContainerID).style. 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_SelectedIndexChanged(object
sender,System.EventArgs e)
{
RadioButtonList rbl = (RadioButtonList)sender;
Control parent = rbl.Parent;
while(!(parent is
System.Web.UI.WebControls.DataGridItem))
{
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:TemplateColumn HeaderText="Mood Today">
<ItemTemplate>
<asp:Image id="imggm" runat="server" Visible="False" ImageUrl="file:///
C:\Inetpub\wwwroot\DashBoard\Moods\laughing.gif"></asp:Image>
<asp:Image id="imgbm" runat="server" Visible="False" ImageUrl="file:///
C:\Inetpub\wwwroot\DashBoard\Moods\sad.gif"></asp:Image>
<asp:Label id=Label2 runat="server" text='<%#
DataBinder.Eval(Container,"DataItem.MoodToday")%>' >Label</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList id=rblmood runat="server" Width="104px"
AutoPostBack="True" SelectedIndex='<
%#SetState(DataBinder.Eval(Container.DataItem,"Moo dToday"))%>'
Height="40px">
<asp:ListItem Value="Good Mood">Good Mood</asp:ListItem>
<asp:ListItem Value="Bad Mood">Bad Mood</asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>

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
2081
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"...
13
1595
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...
9
4591
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...
9
5039
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: ...
2
2834
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...
14
1822
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...
2
3427
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...
7
3189
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...
76
2901
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
2057
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...
0
7326
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,...
1
7046
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...
0
7498
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...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
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...
0
3194
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
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 ...
0
418
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...

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.