Last post Oct 06, 2008 12:54 PM by Bino868
Oct 04, 2008 08:57 AM|Bino868|LINK
Maybe I am wrong with using the Gridview but I know only the way with Classic ASP. I have following problem:
In a Gridview I make a templatefield like:
<asp:Image ID="ImageMemberAvatar" runat="server" CssClass="Avatar" ImageUrl="~/Repository/Bino/Frank.jpg" Width="96" Height="136" />
<asp:Image ID="ImageFrame" runat="server" CssClass="AvatarFrame" ImageUrl="~/library/style/v1/UserAvatar_Mask2.png" Width="102" Height="154" />
<asp:Image ID="ImageOnline" runat="server" CssClass="AvatarOnline" ImageUrl="~/library/style/v1/OnlineSign.gif" Height="9" Width="35" />
<asp:Image ID="ImageFlag" runat="server" CssClass="AvatarFlag" ImageUrl="~/library/app_flags/276.png" Height="11" Width="16" />
<asp:Label ID="LabelMemberCountry" runat="server" CssClass="AvatarCountryCode" Text="DEU"></asp:Label>
The problem is that's tha Data's not in the Database they should be displayed (other table) and I need in Codebehind to Change. To get the Data is not the problem, but how I can display them back?
In this sample I have the country code '276' and I need to change that to 'DEU'. Also to get in the Gridview (not sure it will possible) the status displayed for a member. If the member is online then display the onlinesign.gif, if not then displayed another
Please if someone have any idea what helps let me know,
Oct 05, 2008 07:42 AM|ramireddyindia|LINK
once the data is binded to gridview, if you wants to make any changes, the best way is to implement gridviewrowdatabound event, here we will write code like below.
here suppose, i wants to compare label's text, if it is "376" , i wants to change to "ENU", then i will do like below.
if(e.row.rowtype == datacontroltype.datarow)
Label LabelMemberCountry = (Label)e.Row.FindControl("LabelMemberCountry");
if(LabelMemberCountry.Text == "376")
LabelMemberCountry.Text = "ENU"
also see this link.
Oct 06, 2008 05:28 AM|Bino868|LINK
I try to figure out how this can work. But for now is it not like I was hopeing, because I have to change the File of the Images also and this drives me nuts at the moment.
But thank you for the reply of my post I will come back to you if it was helpfully.
Oct 06, 2008 05:33 AM|ramireddyindia|LINK
My intention is to tell you the way, rowdatabound event works only, But not to give you entire solution.
Oct 06, 2008 12:54 PM|Bino868|LINK
Of course you not make my job and I love a challenge also. Otherwise is it too boring, don't you think. And even if you don't like it but you already gived the solution. Thank you very much.
The only thing what was confusing is that's you wrote in CSharp and I don't like (but of course everyone can use the language he prefer too) this programm language anyway. The way how it works is:
Dim LabelArticleHaeder As Label = e.Item.FindControl("LabelArticleHeader")
Don't wonder, I change the Gridview to Repeater Control. Is much better in my case. But the way is still the same.
Thank you again,