atc
atc

Reputation: 621

Setting values in grid based on my table values using asp.net

I am getting 2 values from my table (it's dynamic, sometimes more than 2) and I need to set this value in a text box of gridview. I am not getting an idea how to set values.Each row contains database values in the grid. I have done up to this level.How can I check both grid value and database values are same. if it is same I need to set that value. Please help me

if (dsBOMInvoice.Tables[0].Rows.Count > 0)
{
    foreach (DataRow dr in dsBOMInvoice.Tables[0].Rows)
    {
        var BOQ_ID = dr["BOQ_ITEM_ID"].ToString();

        foreach (GridViewRow BOMrow in grdBOM.Rows)
        {
            for (int i = 0; i < grdBOM.Columns.Count; i++)
            {
               //I need to place textbox here and set 
               // String cellText = BOMrow.Cells[i].Text;
            }
        }
    }

}

Upvotes: 0

Views: 59

Answers (2)

HNIM600
HNIM600

Reputation: 37

I'm not sure what you want to do here but i think you should convert your column in grid to template and add label or textbox to that templatecolumn, in code behind, you can if your conditions in databound grid

Upvotes: 0

bless
bless

Reputation: 12

Hope this will give answer

if (dsBOMInvoice.Tables[0].Rows.Count > 0)
{
    foreach (DataRow dr in dsBOMInvoice.Tables[0].Rows)
    {
        var BOQ_ID = dr["BOQ_ITEM_ID"].ToString();

        foreach (GridViewRow BOMrow in grdBOM.Rows)
        {
           // step1: find the label or textbox which you wan to check in grid
           // Step2: check with BOQ_ID by using if
           //find the textbox for setting using Findcontrol and set
        }
    }

}

Upvotes: 1

Related Questions