.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

Change image in gridview after binding

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net
 

I have a need to change the image (bound) in a gridview after it has been databound.  Basically i need to assign a photo to a record and I want to change the image url for that row.  I can change the text in any of the cells of the row but I can't seem to find property for the imageurl.

This is what I do to change the text(cell 5).

int index = int.Parse(Session["NSI"].ToString());

GridViewRow row1 = GridView1.Rows[index];
row1.Cells[5].Text = "just some text";


But now I need to change the image url for cell 0

something along the lines of ...

row1.Cells[0].ImageUrl = "~images\photos\12345.jpg";


How do I get to that property?


Thank you.




View Complete Post


More Related Resource Links

Binding the multiple drop down boxes in GridView using JQuery in ASP.NET

  
Here is the code for binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Binding GridView with SqlDataSource at runtime?

  

Hi, I want to create a generic page which contains a gridview and sqldatasource. I want to put these two controls on .aspx (C#) page but bind them at runtime. It should have selectcommand, updatecommand, deletecommand and insertcommand. Stored procedures are created for that. Help is needed to make it. Please post some link or code. Regards, ap.


Gridview with Image Button

  

i have a gridview and i want to perform edit and delete with an image button

but unable to figure out the events and how i m gonna make my grid into edit mode ??

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            onrowcommand="GridView1_RowCommand">
            <Columns>
                <asp:TemplateField HeaderText="S.No">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex+1 %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Edit">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Middle" 
                            ImageUrl="~/image/ico_edit.gif" CommandName="Edit" 
                            onclick="ImageButton1_Click" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Delete">
                    <ItemTemplate>
                        <

change image button image

  

i am making a web form with a VB code behind.  on the form I have a down arrow imageButton that when pressed hides certain data.  what i want to do is change the button to an up arrow and vice versa whenever pressed.  i have both images loaded onto my project already.  any suggestions.

thank you


Change data on gridview bind

  

Hi there,


Simple little problem. i have a gridview that shows products assigned to a customers job. They are displayed in exVAT prices. To make it easier i want to show the inc VAT prices. How can i add VAT to 1 column in this table?


How To display image in GridView as hyperlink

  

Hello Everyone 


Could someone please help me with a little issue....


I was able to save the image in the database as binary....... but now i don´t know how to display it in the GridView as a hyperlink.


I´ve read something about ImageField..... I´d appreciate any help .


=)


Need some help BINDING to Gridview

  

Here is how I set this up....Still not working.

  •     Dim cs As ConnectionStringSettings   
  •     cs = ConfigurationManager.ConnectionStrings("ConnectionStringVendors")   
  •     Dim connString As String = cs.ConnectionString   
  •     Dim dbConnection As New SqlConnection(connString)   
  •     Dim query As String  
  •     Dim query1 As String  
  •   
  •     query = "SELECT keyID, projectNum, projectDescripti
  • Binding xml data (which is return from Url) to gridview

      

    I have used Yahoo BOSS API for internal search. This API return string and i want to bind it with gridview. How can i achieve this following is the code


    string AppId = "sRP_q9bV34HI_zNyuahPFBGnf1SHyBaIKCtvEjB89EuiNJI6fcfSwAFbwAFSsCV_";
     
    //string Query = "site:way2k.com engineering colleges in pune";
    string Query = "colleges in pune"; int NumResults = 10;
         int NumResults = 10;
    System.Net.WebClient webClient = new System.Net.WebClient(); request = string.Format( "http://boss.yahooapis.com/ysearch/web/v1/{1}?appid={0}&format=xml&results={2}", AppId, Query, NumResults); byte[] response = webClient.DownloadData(request); string responseXML = System.Text.UTF8Encoding.UTF8.GetString(response); return responseXML;


    this code returns result in xml format, how can i bind this XML to gridview so that it looks like search result



    Can't change Gridview row colors or styles in the DataBound event

      

    I was highlighting certain rows in my gridview using code like this in the DataBound event:

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int vendorCheck = 0;
                //TODO make this shorter
                if (DataBinder.Eval(e.Row.DataItem, "vendorId") != System.DBNull.Value)
                {

    change css and image url

      
    HiI have a masterpage on a site, in order to use the site the user has to login first. And after that I  would like to customize the masterpage with a unique css file and a unique imageurl for a image on the masterpage. Whar is the preferable way to achive this?
    Categories: 
    ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
    Sql Server  SharePoint  Silverlight  Others  All   

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend