DataGrid Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sweatha
    New Member
    • Mar 2008
    • 44

    DataGrid Problem

    Hello Friends

    I have designed the form with three dropdownlist boxes named Default.aspx. The first DropDownList box (DropDownList1) is filled with movie names. The second DropDownList box(DropDownLis t2)is filled with theatre names and the third DropDownList box (DropDownList3) is filled with dates from sql server. In my Second form(Default2.a spx) ,I have called these dropdown boxes selected value from Default.aspx form using query and populated the GridView1 in the form Default2.aspx. Also I have placed the Panel Control(Panel1) in this Default2.aspx form .Each data in the GridView has made as a link button by using the codings

    HTML Codings:

    <asp:GridView ID="GridView1" runat="server" Style="z-index: 101; left: 355px; position: absolute;
    top: 27px" CellPadding="4" ForeColor="#333 333" GridLines="None " AutoGenerateCol umns="False" OnSelectedIndex Changed="GridVi ew1_SelectedInd exChanged">

    <Columns>
    <asp:TemplateFi eld>
    <ItemTemplate >
    <div>
    <asp:LinkButt on ID="Link1" Text='<%#Bind(" Link1") %>' PostBackUrl='<% #Bind("Link1") %>' OnClientClick=" " runat="Server"> Link1</asp:LinkButton>
    </div>
    </ItemTemplate>
    </asp:TemplateFie ld>
    <asp:TemplateFi eld>
    <ItemTemplate >
    <div>
    <asp:LinkButt on ID="Link2" Text='<%#Bind(" Link2") %>' PostBackUrl='<% #Bind("Link2") %>' runat="Server"> Link2</asp:LinkButton>
    </div>
    </ItemTemplate>
    </asp:TemplateFie ld>
    <asp:TemplateFi eld>
    <ItemTemplate >
    <div>
    <asp:LinkButt on ID="Link3" Text='<%#Bind(" Link3") %>' PostBackUrl='<% #Bind("Link3") %>' runat="Server"> Link3</asp:LinkButton>
    </div>
    </ItemTemplate>
    </asp:TemplateFie ld>
    <asp:TemplateFi eld>
    <ItemTemplate >
    <div>
    <asp:LinkButt on ID="Link4" Text='<%#Bind(" Link4") %>' PostBackUrl='<% #Bind("Link4") %>' runat="Server"> Link4</asp:LinkButton>
    </div>
    </ItemTemplate>
    </asp:TemplateFie ld>
    </Columns>

    <FooterStyle BackColor="#5D7 B9D" Font-Bold="True" ForeColor="Whit e" />
    <RowStyle BackColor="#F7F 6F3" ForeColor="#333 333" />
    <EditRowStyle BackColor="#999 999" />
    <SelectedRowSty le BackColor="#E2D ED6" Font-Bold="True" ForeColor="#333 333" />
    <PagerStyle BackColor="#284 775" ForeColor="Whit e" HorizontalAlign ="Center" />
    <HeaderStyle BackColor="#5D7 B9D" Font-Bold="True" ForeColor="Whit e" />
    <AlternatingRow Style BackColor="Whit e" ForeColor="#284 775" />

    </asp:GridView>

    In my code behind,

    I have given the coding as

    protected void Page_Load(objec t sender, EventArgs e)
    {
    object obj;
    obj = (object)Session["movie"];

    object obj1;
    obj1 =(object)Sessio n["theatre"];

    object obj2;
    obj2 = (object)Session["date"];
    SqlConnection con = new SqlConnection(" user id=sa;password= cast;database=T HEATRE;server=A URORA-SERVER;");
    con.Open();
    string dgstr = "select s.showtime from ShowDetails s,TheatreMaster t, MovieMaster m where t.tname= '" + obj1.ToString() + "' and m.moviename='" + obj.ToString() + "' and s.date='" + obj2.ToString() + "'";
    SqlCommand dgcmd=new SqlCommand(dgst r,con);
    string dgstr2 = "select count(showtime) from ShowDetails";
    SqlCommand dgcmd1=new SqlCommand(dgst r2,con);
    SqlDataReader DRCount = dgcmd1.ExecuteR eader();
    DataTable dt = new DataTable();
    dt.Columns.Add( new DataColumn("Lin k1", typeof(string)) );
    dt.Columns.Add( new DataColumn("Lin k2", typeof(string)) );
    dt.Columns.Add( new DataColumn("Lin k3", typeof(string)) );
    dt.Columns.Add( new DataColumn("Lin k4", typeof(string)) );

    if (DRCount.Read() )
    {
    int noOfRows;
    if ((int)DRCount[0] % 4 == 0)
    {
    noOfRows = (int)DRCount[0] % 4;
    }
    else
    noOfRows = ((int)DRCount[0] % 4) + 1;
    DRCount.Close() ;
    SqlDataReader DR1 = dgcmd.ExecuteRe ader();
    for (int i = 0; i <=noOfRows; i++)
    {
    DataRow dr = dt.NewRow();
    if (DR1.Read())
    {
    dr["Link1"] = DR1[0];

    }
    //dr = dt.NewRow();
    if (DR1.Read())
    {
    dr["Link2"] = DR1[0];

    }

    //dr = dt.NewRow();
    if (DR1.Read())
    {
    dr["Link3"] = DR1[0];
    }

    if (DR1.Read())
    {
    dr["Link4"] = DR1[0];
    }
    dt.Rows.Add(dr) ;
    }
    }
    GridView1.DataS ource = dt;
    GridView1.DataB ind();
    }

    Here the obj,obj1,obj2 are the values of the DropDownList boxes(Movie, Theatre & Date) in the Previous Form.

    Now the thing is, if I click any data(link button) inside the datagrid, then the Panel Control(Panel1) which is on the outside of the Gridiew should get visible.

    For that I have given the Script codings as

    <script type="text/javascript" language="javas cript">
    function AddToList()
    {
    var drop = document.getEle mentById('<%=_P anel1.ClientID. visibility.visi ble="True"%>');
    </script>

    But it is showing the error as

    Error 1 The name '_Panel1' does not exist in the current context C:\Documents and Settings\user\M y Documents\Visua l Studio 2005\WebSites\A JAXEnabledWebSi te5\Default2.as px 11

    So the Panel1 is not getting visible.


    -sweatha
Working...