2014年7月13日 星期日

[RESOLVED] code is not working properly


When page is loaded then it show all things in video and data but when page on vieo or audio is clicked then everything started working perfectly



asp code


---------------------


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>






















AllowPaging="True"

PageSize="2" OnPageIndexChanging="GridView1_PageIndexChanging">





























<%----%>













OnRowDataBound="grdvwvideo_RowDataBound" AllowPaging="True"

onpageindexchanging="grdvwvideo_PageIndexChanging" PageSize="1">








































OnRowDataBound="GridView2_RowDataBound" AllowPaging="True"

onpageindexchanging="GridView2_PageIndexChanging" PageSize="1"

>


















































-----------------------


C# code


------------


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;




public partial class test : System.Web.UI.Page

{

SqlConnection con = new SqlConnection("server='WOLVERINE-PC'; database='mcura'; integrated security='true'");

//SqlDataReader drd;

//SqlCommand com;

SqlDataAdapter da;

DataSet ds = new DataSet();



protected void Page_Load(object sender, EventArgs e)

{

if (!Page.IsPostBack)





data();

videodata();

audiodata();





}

private void data()

{

da = new SqlDataAdapter("GET_IMAGE", con);



da.Fill(ds);

GridView1.DataSource = ds;

GridView1.DataBind();




}



private void videodata()

{

da = new SqlDataAdapter("GET_VIDEO", con);


da.Fill(ds);

grdvwvideo.DataSource = ds;

grdvwvideo.DataBind();




}

private void audiodata()

{

da = new SqlDataAdapter("select * from multimedia where filetype='audio'", con);


da.Fill(ds);

GridView2.DataSource = ds;

GridView2.DataBind();




}


protected void grdvwvideo_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.DataRow)

{

Literal media = (Literal)e.Row.FindControl("Literal1");

string mediaId = "media-" + media.UniqueID;

string str = "";


if (media.Text.EndsWith(".mp4"))

{

str = "




protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.DataRow)

{

Literal media = (Literal)e.Row.FindControl("Literal2");

string mediaId = "media-" + media.UniqueID;

string str = "";


if (media.Text.EndsWith(".mp4"))

{

str = "


media.Text = str;

}

}

protected void grdvwvideo_PageIndexChanging(object sender, GridViewPageEventArgs e)

{

grdvwvideo.PageIndex = e.NewPageIndex;

videodata();

}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)

{

GridView1.PageIndex = e.NewPageIndex;

data();


}

protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)

{

GridView2.PageIndex = e.NewPageIndex;

audiodata();

}

}


----------------



Either move the Dataset ds to be inside every method so it's not a global variable, or make sure you're pointing to the right dataset table (ds.Tables[0] or [1]) when binding.



Thank you very much


I am trying this from last 3 days.



沒有留言:

張貼留言