0

Hi,
I have a grid view having images and text.. i used handler to display image. but after implementing the code to display image,,, autogenerated edit/delete options are not displaying
Data Fields........
mpId...int(Text),
mpName.... varchar(Text),
mpLocation... varchar (dropdown list),
mpImageF.. image ,
mpGender... varchar(radio button list)
Please Guide me how i edit and delete record in gridview
Code is ......

1
Contributor
1
Reply
5
Views
5 Years
Discussion Span
Last Post by Ashfa
0
            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            //        Handler.ashx
            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

             public void ProcessRequest (HttpContext context) {
                    string imgID = context.Request.QueryString["ID"].ToString();
                    SqlCommand cmd = new SqlCommand("Select * from MissingPerson where mpId="+imgID, con);
                    con.Open();
                    SqlDataReader Dr = cmd.ExecuteReader();
                    Dr.Read();

                    context.Response.BinaryWrite((byte[])Dr["mpImageF"]);
                    con.Close();
                }


            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            //        UploadedByMe.aspx
            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" >
            <Columns>
              <asp:TemplateField HeaderText = "Id" Visible= "false">
                <ItemTemplate>
                <asp:Label ID="l" Text= '<%# Eval("mpId") %>' runat="server" />
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText = "Picture">
                <ItemTemplate>
                <img  height="100" width = "100" src="Handler.ashx?ID=<%# Eval("mpId") %>"  />
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText= "Name">
                <ItemTemplate>
                <asp:Label ID= "lblname" runat="server" Text = '<%# Eval("mpName") %>' />
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText= "Gender">
                <ItemTemplate>
                <asp:Label ID= "lbl9" runat="server" Text = '<%# Eval("mpGender") %>' />
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText= "Location" >
                <ItemTemplate >
                <asp:Label ID = "loc"  runat = "server" Text = '<%# Eval("mpLocation") %>' />
                </ItemTemplate>
                </asp:TemplateField>

                </Columns>
                </asp:GridView>
            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            //        UploadedByMe.aspx.cx
            //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            protected void Page_Load(object sender, EventArgs e)
                {
                    if (!IsPostBack)
                        BindGrid();
                }
             void BindGrid()
                {
                    SqlDataAdapter da = new SqlDataAdapter("Select * from MissingPerson", con);
                    DataSet Ds = new DataSet();
                    da.Fill(Ds);
                    GridView1.DataSource = Ds;
                    GridView1.DataBind();
                }

Edited by Ashfa

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.