خرید بک لینک

Vote count: 0

I've been trying to figure out how to do this for a while now, because the ID of the Image Button I created ('titanBtn') is not recognised in my code behind file. Which would allow me to simply write 'titanBtn.ImageUrl =" but alas, the code behind says it doesn't exist.

All I am trying to do with this code, is take a string read from the Db, that specifies the filename of the image (the appropriate images are named after the element type of each object), and puts this in a concatenated string that specifies the ImageUrl.

<asp:Repeater ID="titanRptr" runat="server">
    <ItemTemplate>
        <table>
            <tr class="tr1">
                <td><%# Eval("TitanName") %></td>
                <td>
                    <asp:ImageButton ID="titanBtn" runat="server" Width="100px" Height="100px" OnClick="titanBtn_Click" />
                </td>
                <td>Level: <%# Eval("char_lvl")%>
                    <br />
                    Step: <%# Eval("step")%>
                    <br />

                </td>
            </tr>
        </table>
    </ItemTemplate>
</asp:Repeater>

code behind

using (SqlCommand cmd2 = new SqlCommand("getElement", co))
                    {
                        cmd2.CommandType = CommandType.StoredProcedure;
                        cmd2.Parameters.AddWithValue("@uid", titanElement);
                        using (SqlDataAdapter sda = new SqlDataAdapter(cmd2))
                        {
                            SqlDataReader reader;
                            co.Open();
                            reader = cmd2.ExecuteReader();
                            while (reader.Read())
                            {

                                titanImage = Convert.ToString(reader["Element"]);
                                titanBtn.ImageUrl = "images/" + titanImage+ ".gif"; //"The name 'titanBtn' does not exist in the current context"
                                titanRptr

                            }
                            co.Close();
                        }
                    }

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 7 خرداد 1395 ساعت: 8:08

صفحه بندی