protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindData(); } } private void BindData() { if (ddlTguidedit.SelectedIndex==0) { string strQuery = "SELECT [Pdfid],[Arpdf_name],[Arpdf_des],[pdf_date] FROM [books_alaa].[dbo].[Tbl_uploadpdf]"; SqlCommand cmd = new SqlCommand(strQuery); GridView1.DataSource = GetData(cmd); GridView1.DataBind(); } else { string strQuery = " SELECT Pdfid, Enpdf_name AS Arpdf_name, Enpdf_des AS Arpdf_des, pdf_url, pdf_date FROM Tbl_uploadpdf"; SqlCommand cmd = new SqlCommand(strQuery); GridView1.DataSource = GetData(cmd); GridView1.DataBind(); } } private DataTable GetData(SqlCommand cmd) { DataTable dt = new DataTable(); SqlConnection con = new SqlConnection(strConnString); SqlDataAdapter sda = new SqlDataAdapter(); cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); sda.SelectCommand = cmd; sda.Fill(dt); return dt; } protected void ddlTguidedit_SelectedIndexChanged(object sender, EventArgs e) { if (ddlTguidedit.SelectedIndex == 0) { string strQuery = "SELECT [Pdfid],[Arpdf_name],[Arpdf_des],[pdf_date] FROM [books_alaa].[dbo].[Tbl_uploadpdf]"; SqlCommand cmd = new SqlCommand(strQuery); GridView1.DataSource = GetData(cmd); GridView1.DataBind(); } else { string strQuery = " SELECT Pdfid, Enpdf_name AS Arpdf_name, Enpdf_des AS Arpdf_des, pdf_url, pdf_date FROM Tbl_uploadpdf"; SqlCommand cmd = new SqlCommand(strQuery); GridView1.DataSource = GetData(cmd); GridView1.DataBind(); } }
Tbl_uploadpdf
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)