I have normal grid in ASP.NET and I am converting it into webdata grid.
Now my grid has functionalities of opening file, copy file, edit description of file, emailing file and deleting file.
It is based on documents.
Now suppose if I take example of deleting file the original code is:
protected void lbEmailDocument_Click(object sender, CommandEventArgs e)
{
int index = Int32.Parse(e.CommandArgument.ToString());
Session["strDocumentToAttach"] = ((Label)gvDocuments.Rows[index].Cells[0].FindControl("lblPath")).Text;
Session["strSubject"] = "Case Document E-mail (Case # " + lblCaseNumber.Text.Trim() + ")";
Session["strNote"] = "Please find the attached document " + ((Label)gvDocuments.Rows[index].Cells[0].FindControl("lblFileName")).Text;
ScriptManager.RegisterStartupScript(Page, this.GetType(), "myPopUp", "<script language='Javascript'>mywin=window.open('Case_Email.aspx?CaseID=" + lblCaseID.Text + "', '', 'location=0,status=0,resizable=1,scrollbars=1,height=920px, width=1250px');mywin.moveTo(0,0);</script>", false);
// Response.Redirect("Case_Email.aspx?CaseID=" + lblCaseID.Text);
}
------------------------------------------------------------------------------------------------------------------------------
Now when I change this : Instead of Rows[index].Cells[0] I am not able to access the cell value.
Please guide me through, How to change it.
Hi beburulesforever,
Thank you for posting in the community.
I have created a sample for you demonstrating how to access the different cells in a row in WebDataGrid (both using the column key and by column index). In WebDataGrid the Items collection is used to access the cells in a row as such :
protected void Button1_Click(object sender, EventArgs e){ //here the item (cell) is accessed by column key Label1.Text = WebDataGrid1.Rows[0].Items.FindItemByKey("Name").Value.ToString(); //item's templated label is accessed (here the item is accessed by index) Label1.Text = Label1.Text + " " + ((Label)WebDataGrid1.Rows[0].Items[0].FindControl("TemplatedLabel")).Text;
Attached is also a simple sample illustrating this scenario. Please do not hesitate to contact me if you need further assistance.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support
The DataGrid's row and cell values should be accessible on the server in any case (no javascript is needed). If you need to access a cells value on the client you can use something like :
$find("WebDataGrid1").get_rows().get_row(0).get_cell(0).get_value()
Detailed information on WebDataGrid's CSOM can be found at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=WebDataGrid~Infragistics.Web.UI_namespace.html
Please let me know if you have any questions.