Quote:
quote:Originally posted by krasnokojiy
it looks like that i've written wrong index but after all i tried another indexes ; for example , {0,1,2,3,4,5} but nothing happened
|
Thats because you are binding to controls. Normally when you want to get the Text value of a cell, you simply call your databind method in the cell outside of a control like this:
<asp:TemplateField HeaderText="SID">
<EditItemTemplate>
<asp:Label ID="lblID" runat="server"></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"SID") %> </ItemTemplate>
</asp:TemplateField>
To do what you want without changing your code you can do something like:
protected void LinkButton1_Click(object sender, EventArgs e)
{
StringBuilder str = new StringBuilder();
for (int i = 0; i < gv.Rows.Count; i++)
{
GridViewRow row = gv.Rows[i];
bool isChecked = ((CheckBox)row.FindControl("chkSec")).Checked;
if (isChecked)
{
Label lbl = (Label)row.FindControl("lblID");
// Column 2 is the name column
str.Append(lbl.Text);
}
}
Response.Write(str.ToString());
}
hth.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========