سؤال

I have created a web page that displays a table. Most of the cells of the table are already filled in but some of them require user input. I was wondering if there is some way to associate an onClick event with these data cells that displays a drop down list of the possible entries for the cell. I have Googled and Googled but I haven't come up with anything. So I'm not even sure this is possible.

Any advice is appreciated.

Regards.

هل كانت مفيدة؟

المحلول 3

This problem was solved by putting placeholders within spans and then replacing the innerHTML:

<span id="s2" runat="server"><asp:PlaceHolder ID="p2" runat="server"></asp:PlaceHolder></span>

نصائح أخرى

I am pretty sure you are going to have to use some sort of client side scripting to accomplish this. Since you have c# flagged as the server side language, I will assume you are using a gridview, so something like this

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
        for (int i = 0; i < e.Row.Cells.Count; i++)
            e.Row.Cells[i].Attributes.Add("onclick", "getDropDown");
}

Rather than try to make the data cell itself create the list, you could put an ASP.Net drop down box in each table cell, mess with the settings so it is equal in size with the table cell , and fill the contents of the drop down boxes on the page load.

EDIT: See the MSDN page: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.dropdownlist.dropdownlist.aspx

There is a very good page_load example there.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top