Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all
I am developing movie theater seat booking website like www.bookmyshow.com[^], for that i have place image as Seats in asp:gridview(all cells), for selection of seat click on Image(cell) at that time i need that cell value(Seat No) where i clicked Image(cell) in gridview.

This binding based on Database
In Database Cell value=0 Then in gridviewCell no image
In Database Cell value=1 Then in gridviewCell image indicate available Seat
In Database Cell value=2 Then in gridviewCell image indicate Selected Seat
In Database Cell value=3 Then in gridviewCell image indicate Booked Seat

This Database is every time changes by selecting deferent Theater.
So theater layout is not fix to some Rows & Columns,
so this all binding is done dynamically.

If possible send me Sample code.

Please help me.
Posted
Updated 3-Oct-11 7:08am
v8

As far as getting cell values is concerned, maybe this[^] can help you out.
 
Share this answer
 
You can add ImageButton control instead of simple Image control, the ImageButton control has an additional property called CommandParameter which you can bind with your customId (Say SeatNo) while adding to grid cells,

Whenever you will click the button, event bubbling will happen and Gridview1_ItemCommand event will be executed, in that event handler you can identify, which ImageButton is clicked through its CommandParameter property.
 
Share this answer
 
Comments
MahiGurrala.in 26-Sep-11 5:01am    
I tried like that but not getting values from images when clicked.
If possible give me Simple code for getting values from images.
Thank you...
Hi

I tried some code for your requirement

Check my code for it

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language ="javascript" >


    
    </script>
</head>
<body >
    <form id="form1" runat="server">
    <div>
        <asp:datalist id="DataList1" runat="server" repeatcolumns="5" xmlns:asp="#unknown">
            RepeatDirection ="Horizontal" onitemcommand="DataList1_ItemCommand" 
            onitemdatabound="DataList1_ItemDataBound" >
        <HeaderTemplate >
        </HeaderTemplate>
        <itemtemplate>
         <table width="20" height="20">
          <tr>
            <td>
                <asp:linkbutton id="LinkButton1" runat="server" commandname="book" commandargument="<%#Eval("vid") %>"><img src="Images/Winter.jpg" width="19" height="19" /></asp:linkbutton>
            </td>
          </tr>
         </table>
        </itemtemplate>
        <footertemplate>
        
        </footertemplate>
        </asp:datalist>
    </div>
    </form>
</body>
</html>


And code behin file contains following code

C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        MylocalDataClassesDataContext db = new MylocalDataClassesDataContext();
        var g = from d in db.VideoTabs
                select d;
        DataList1.DataSource = g;
        DataList1.DataBind();
    }
}

protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
    if (e.CommandName == "book")
    {
        // write for booking here
    }
}
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        LinkButton rdblist = (LinkButton)e.Item.FindControl("LinkButton1");
        //check database values here

        rdblist.Text = "<img src="\"Images/Waterlilies.jpg\"" width="\"19\"" height="\"19\"" />";
    }
}

Here you've to check the database values in databound event
I hope you can understood What I did.

All the Best
 
Share this answer
 
Comments
MahiGurrala.in 26-Sep-11 5:04am    
I dint understood your code If possible give me Clearly.
Thank you.
Muralikrishna8811 26-Sep-11 6:12am    
is it wrking for you
MahiGurrala.in 26-Sep-11 23:40pm    
Yes its working for me but not understood and if i run above code getting errors So give me clearly once again.
Thank you.
Muralikrishna8811 27-Sep-11 4:27am    
what error you got while running

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900