I am using a GridView to List contacts linked to a logged in User.
I can successfully bind the Gridview with a DataTable. And the values in the GridView are correctly displayed.
I have a BoundField at Index 0 of the GridView which pulls a value from a Column in the DataSource (datatable).
The problem I am facing is that all the values in the cells are coming back as empty strings.
Can Anyone help me understand what I am leaving out and what I am doing wrong.
Code is as below:
Expand|Select|Wrap|Line Numbers
- protected void grdContactList_RowCommand(Object sender, GridViewCommandEventArgs e)
- {
- Global.BindGridView(ref grdContactList, Global.g_dtContacts);
- if (e.CommandName == "EditContact")
- {
- string strCmdArg = Convert.ToString(e.CommandArgument);
- string strContactID = grdContactList.Rows[Convert.ToInt32(strCmdArg)].Cells[0].Text;
- Server.Transfer("EditContact.aspx?contactid=" + strContactID);
- }
- else if (e.CommandName == "DeleteContact")
- {
- string strCmdArg = Convert.ToString(e.CommandArgument);
- string strContactID = grdContactList.Rows[Convert.ToInt32(strCmdArg)].Cells[0].Text;
- string strAgentID = grdContactList.Rows[Convert.ToInt32(strCmdArg)].Cells[1].Text;
- Contact.DeleteContact(strContactID, strAgentID);
- }
- }
- The values of both strContactID and strAgentID are coming back as "".
- BindGridView(...) is basically...
- GridView.Datasource = dtDatatable;
- GridView.Databind();