Regarding grid view

Hi all

I am using gridview to insert the role for an employee in a project.
when i edit that project i have to display the gridview for the user with the assigned role

but i am not able to get it

in aspx page
------

<td colspan="2">
<table >
<tr>
<td align="center" valign="top">
<div style="overflow:auto;height:170px; width:170px;">
<asp:GridView ID="dgUsers" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="UserId" Visible="false" HeaderText="User ID"/>
<asp:BoundField DataField="UserName" HeaderText="User Name" />
<asp:TemplateField HeaderText="Role">
<ItemTemplate>
<table>
<tr>
<td>
<asp:DropDownList ID="drpRole" runat="server" AutoPostBack="true" EnableViewState="true">
<asp:ListItem >User</asp:ListItem>
<asp:ListItem >PM</asp:ListItem>
<asp:ListItem >TM</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</table>
</td>

In page load
--------

DataTable dt = new DataTable();
SqlDataAdapter das = new SqlDataAdapter("select u.UserID, FirstName+' '+MidName+' '+LastName as [UserName], UserTypeId from tblprojectallocation PA, tblUsers U where U.Userid = Pa.Userid and PA.Projectid = " + Request["id"].ToString(), cn);
cn.Open();
das.Fill(dt);
cn.Close();
dgUsers.DataSource = dt;
dgUsers.DataBind();

when i am saving into the database
------------------

int intUserType = 0;
string szUserId;
foreach (GridViewRow grrow in dgUsers.Rows)
{

szUserId = grrow.Cells[0].Text;
intUserType = ((DropDownList)grrow.FindControl("drpRole")).SelectedIndex;
cm = new SqlCommand("insert into tblProjectAllocation (ProjectID,UserID,UserTypeID) values(" + nTemp + "," + Convert.ToInt32(szUserId) + "," + intUserType.ToString() + ")", cn);
cn.Open();
cm.ExecuteNonQuery();
cn.Close();
}

pls help me
[3993 byte] By [tis707] at [2007-11-20 9:45:25]