Advertisement
Advertisement
| 05.10.2008 at 09:03PM PDT, ID: 23392356 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: |
//Data Access code
public DataTable getTable(string strQry)
{
SqlDataAdapter sqlAdp = new SqlDataAdapter(strQry, strSqlConn);
try
{
strSqlConn.Open();
DataSet ds = new DataSet();
sqlAdp.Fill(ds, "Temp");
return ds.Tables[0];//This is where am getting error
}
catch (SqlException ex)
{
throw ex;
}
catch (Exception ex)
{
throw ex;
}
finally
{
sqlAdp.Dispose();
sqlAdp = null;
strSqlConn.Close();
}
}
//PracticeGridview.cs code
public partial class PracticeGridview : System.Web.UI.Page
{
DataAccess da = new DataAccess();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
StringBuilder sb = new StringBuilder();
sb.Append("Select AppID,Application from Approval");
DataTable dt = new DataTable();
dt = da.getTable(sb.ToString());
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button1_Click1(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
int AppID = (int)GridView1.DataKeys[i][0];
CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("chkSelect");
if (cb.Checked)
{
StringBuilder sb = new StringBuilder();
// sb.Append(GridView1.Rows[i].Cells[1].ToString());
sb.Append("UPDATE Approval SET Approved='true' WHERE AppID=@AppID ");
sb.Replace("@AppID", AppID.ToString());
da.getTable(sb.ToString());
BindGrid();
}
}
}
}
|