Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to get column value in grid View

$
0
0

Hello My first Language is German so bear with my English

FIRST vIEW THE SCREEN SHOT PLEASE

I am new to asp.net  i am making small application to generate reports in which user give criteria just liek we do in sql server  i have two grid view in accordion section then there is button  so Both GridView has headers that  Name , Output and Filter

Name shows the Column of database fields, output column has check box if user check box it will only display those columns and filter is text box in which we filter our results

basically i am just trying to do this like sql server in which user check columns to display and also provide filter criteria and then sql query modified according to the grid values.

i have attached the screen shot of grid view kindly view it please You will have idea what i am tyring to say 

now i want some help in filter criteria 

suppose user check ref Code, School,Program, Name in the grid view and press show button

it generates query

select RefCode,School,Program,Name from Applicant.

now i want to apply where clause if user write something in filter text box which i can not do kindly help me out and view the screen shot my desire outcome is if user check column and also write some value in RefCode filter textbox let suppose '0565-01' and in School Text user write SBE

it should generate  sql

select RefCode,School,Program,Name from Applicant where (RefCode='0565-01')and (School='SBE');


my code for show button which generate simple select statement without where clause is below.

protected void Button2_Click(object sender, EventArgs e) { String output = ""; String filter = ""; foreach (GridViewRow row in gvExperience.Rows) { CheckBox cb = (CheckBox)row.FindControl("CheckBox1"); if (cb.Checked == true) { output += row.Cells[0].Text.ToString() + ','; // get the Name of columns and concate in output variable

} } output = output.Remove(output.LastIndexOf(","), 1) string sql = "select " + output + " from Applicant"; // display the query bindoutput(sql); // pass this query and bind the new gridview which contain generated sql }



Azeem


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>