how to have unique datagridview

Posted by Oswaldlily under VB.NET on 4/4/2014 | Points: 10 | Views : 735 | Status : [Member] | Replies : 1
I need popup child datagridview on clicking of any cell in datagridview

each cell has different popup datagridview values...Nothing is unique..

When i come back to rowindex 0,colindex 0,it should have its corresponding entered values..

How to achieve this??


my code for rowindex 0 alone:

*Have 2 child datagridview and 1 parent datagridview

*On clicking of rowindex 0-colindex 0=>child datagridview1 opens

*On clicking of rowindex 0-colindex 1=>child datagridview2 opens


smiliarly i need for all rowindex..i could not have separate new deatagridview for all cells ..

How to limit datagridviews and achieve for all cells???




Responses

Posted by: Saranpselvam on: 4/7/2014 [Member] Starter | Points: 25

Up
0
Down
Hi


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
int i = 0;

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#fed66c'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;");
string[] stringSeparators = new string[] { "~" };
string[] splitLinkedcolumns = null;
if (appendColumnName != null)
{
splitLinkedcolumns = appendColumnName.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);


QueryString = null;
foreach (DataRow getkeyandvalue in DTParameter.Rows)
{

TableCell Getparametercolumnvalue = null;
if (objrpt.Tables[0].Columns[Convert.ToString(getkeyandvalue[0])] != null)
{
Getparametercolumnvalue = e.Row.Cells[objrpt.Tables[0].Columns[Convert.ToString(getkeyandvalue[0])].Ordinal];
string getParameter = getkeyandvalue[1].ToString();
QueryString += getParameter + "=" + HttpUtility.UrlEncode(Getparametercolumnvalue.Text) + "&";
}
}


foreach (string splitedColumns in splitLinkedcolumns)
{
TableCell getcellval = e.Row.Cells[objrpt.Tables[0].Columns[splitedColumns].Ordinal];
if (getcellval != null && getcellval.Text != "0" && getcellval.Text.Trim() != "")
{
string InputQuerystring = "FrmDetailedReportPOPUp.aspx?" + QueryString + "@ColumnName=" + HttpUtility.UrlEncode(splitedColumns) + "&@Region=" + drpUser.SelectedValue + "&@LOB=" + DRP_LOB.SelectedValue + "&@DateOption=" + ddl_date.SelectedItem.Text;
HttpBrowserCapabilities strBrowserInfo = Request.Browser;

if (strBrowserInfo.Type.StartsWith("I") && strBrowserInfo.MajorVersion < 7)
{

getcellval.Text = "<a href='FrmDetailedReport.aspx?" + QueryString + "@ColumnName=" + HttpUtility.UrlEncode(splitedColumns) + "'>" + getcellval.Text + "</a>";
}
else
{
getcellval.Text = "<a href=" + InputQuerystring + " onclick='basicPopup(this.href);return false'>" + getcellval.Text + "</a>";
}



}
}
}



}




if (e.Row.RowType == DataControlRowType.DataRow)
{

if (objrpt.Tables[0].Columns.Contains("Grand Total"))
{

e.Row.Cells[objrpt.Tables[0].Columns["Grand Total"].Ordinal].BackColor = ColorTranslator.FromHtml("#bfc2d0");
// e.Row.Cells[objrpt.Tables[0].Columns["Grand Total"].Ordinal].Font.Bold = true;
// e.Row.Cells[objrpt.Tables[0].Columns["Grand Total"].Ordinal].ForeColor = System.Drawing.Color.White; ;
}
//This commented part of code used for finding subtotal in any number of rows and columns dynamically
//int getNumberofcells = e.Row.Cells.Count;
//if (getNumberofcells > 0)
//{
// getSubTotalColumn++;
// for (i = 0; i < getNumberofcells; i++)
// {
// if (e.Row.Cells[i].Text == "Sub-Total")
// {

// e.Row.BackColor = System.Drawing.Color.Gray;

// }
// }

//}

if (e.Row.Cells[0].Text == "Sub-Total")
{
//e.Row.BackColor = ColorTranslator.FromHtml("#fed66c");
e.Row.Font.Bold = true;
// e.Row.BorderColor = System.Drawing.Color.Red;
//e.Row.BorderWidth = 2;
e.Row.Font.Size = 10;
getSubTotalColumn = 0;
}
else if (e.Row.Cells[1].Text == "Sub-Total")
{
//e.Row.BackColor = ColorTranslator.FromHtml("#fed66c");
e.Row.Font.Bold = true;
// e.Row.BorderColor = System.Drawing.Color.Red;
// e.Row.BorderWidth = 2;
e.Row.Font.Size = 10;
getSubTotalColumn = 1;
}
else if (e.Row.Cells[2].Text == "Sub-Total")
{
//e.Row.BackColor = ColorTranslator.FromHtml("#fed66c");
e.Row.Font.Bold = true;
//e.Row.BorderColor = System.Drawing.Color.Red;
// e.Row.BorderWidth = 2;
e.Row.Font.Size = 10;
getSubTotalColumn = 2;
}

}

// adding grand Total

if (e.Row.RowType == DataControlRowType.Footer)
{
try
{
if (DTTotalCloumns != null)
{

foreach (DataRow getkeyandvalueForTotal in DTTotalCloumns.Rows)
{
//TempDV = objrpt.Tables[0].DefaultView;
if (getSubTotalColumn != 100)
{
string getColumnName = Convert.ToString(objrpt.Tables[0].Columns[getSubTotalColumn].ColumnName);
string FilterCondition = getColumnName + " = Sub-Total";
//DataRow[] result = objrpt.Tables[0].Select(FilterCondition);

foreach (DataRow DR in objrpt.Tables[0].Select())
{
if (DR[getColumnName].ToString() == "Sub-Total")
{
DR.Delete();
}
}
objrpt.Tables[0].AcceptChanges();

}
TableCell GetparametercolumnvalueForTotal = null;
if (objrpt.Tables[0].Columns[Convert.ToString(getkeyandvalueForTotal[0])] != null)
{

GetparametercolumnvalueForTotal = e.Row.Cells[objrpt.Tables[0].Columns[Convert.ToString(getkeyandvalueForTotal[0])].Ordinal];

Label lbltxt = new Label();
//lbltxt.Text = objrpt.Tables[0].Compute("Sum([" + objrpt.Tables[0].Columns[Convert.ToString(getkeyandvalueForTotal[0])] + "])", " ").ToString();
lbltxt.Text = Convert.ToString(objrpt.Tables[0].Compute("Sum([" + objrpt.Tables[0].Columns[Convert.ToString(getkeyandvalueForTotal[0])] + "])", " "));

lbltxt.ForeColor = System.Drawing.Color.Black;

e.Row.Cells[objrpt.Tables[0].Columns[Convert.ToString(getkeyandvalueForTotal[0])].Ordinal].Controls.Add(lbltxt);
e.Row.Cells[0].Text = "GrandTotal";


}

}

}
}
catch (Exception ex)
{
//Response.Redirect("Index.aspx?err" + ex.Message);
}




}

}
catch (Exception ex)
{
Response.Redirect("Index.aspx?err" + ex.Message);
}


//end Grand Total
}

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response