well i am new to Grid View , so i am taking a simple scenario. well i have a visual webpartin sharepoint ; i have added a grid view with first column is of CheckBox Type & it has a Button & aLabel
i populate the grid view from an array of cities & i want that when button is clicked all the checked cities are appended in to the label. code is below.
protected void Page_Load(object sender, EventArgs e)
{
string[] States = new string []{ "Delhi", "Mumbai", "Pune", "Indaore" };
gvStates.DataSource = States;
gvStates.DataBind();
gvStates.Visible = true;
btnShow.Click += new EventHandler(btnShow_Click);
}
void btnShow_Click(object sender, EventArgs e)
{
// what should i write here to append checked value to label
// lblCites.Text +=
}
while working i found that when button is clicked the page_load function build the grid view again & there fore all check boxes are initialised .
please complete my code !!!!!
i do not want to do the same by using Javascript. i want to do this by C# only
& if possible please tell me the way how can i put a checkbox near "Show" button that is used to check all the check boxes.
thanks in advance!!
This tutorial explains exactly what you need