Click here to Skip to main content
15,891,184 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionremote connections Pin
Rami Said Abd Alhalim14-Mar-07 1:30
Rami Said Abd Alhalim14-Mar-07 1:30 
AnswerRe: remote connections Pin
Colin Angus Mackay14-Mar-07 1:47
Colin Angus Mackay14-Mar-07 1:47 
GeneralRe: remote connections Pin
Rami Said Abd Alhalim14-Mar-07 2:32
Rami Said Abd Alhalim14-Mar-07 2:32 
QuestionHow to get the Clients Operating System in asp.net 1.1 Pin
RaviJJain14-Mar-07 1:06
RaviJJain14-Mar-07 1:06 
AnswerRe: How to get the Clients Operating System in asp.net 1.1 Pin
kubben14-Mar-07 14:44
kubben14-Mar-07 14:44 
QuestionProblem with paging Pin
anujose14-Mar-07 0:39
anujose14-Mar-07 0:39 
AnswerRe: Problem with paging Pin
ToddHileHoffer14-Mar-07 2:08
ToddHileHoffer14-Mar-07 2:08 
QuestionImages in datagrid! Pin
nclauder14-Mar-07 0:14
nclauder14-Mar-07 0:14 
Hi,
I have a datagrid that Inserts data into sql datbase, and amongest
there is a column that has a radiobuttonlist, the radiobuttonlist
contains two radiobuttons one with Good Mood and the otherone with bad
moods. In the column I placed two images where one shows a happy face
and the other one a sad face and I want when a user selects
radiobutton Good Mood the image with a happy face is inserted. but I'm
having a problem when I select radiobutton Good Mood I only get Good
Mood inserted but not the image. How should I do this? here is the
code I'm using:

DataTable table = new DataTable();
private DataTable Fill()
{
SqlDataAdapter adapter = new SqlDataAdapter("select * from
dbo.DashBoard", con);
adapter.Fill(table);
return table;


}


private void Bind()
{
dgis.DataSource = table;
dgis.DataBind();

}


private void InsertEmpty()
{
table.Rows.InsertAt(table.NewRow(), 0);

}


private void dgis_ItemCommand(object
source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
// stop editing
dgis.EditItemIndex = -1;
switch (e.CommandName)
{
case "Insert":
break;
case "Update":
System.Web.UI.WebControls.TextBox st=new
System.Web.UI.WebControls.TextBox();
st=(System.Web.UI.WebControls.TextBox)e.Item.Cells[6].FindControl("txtobjac­h");
System.Web.UI.WebControls.TextBox st1=new
System.Web.UI.WebControls.TextBox();
st1=(System.Web.UI.WebControls.TextBox)e.Item.Cells[5].FindControl("txtobj"­);
System.Web.UI.WebControls.TextBox st2=new
System.Web.UI.WebControls.TextBox();
st2=(System.Web.UI.WebControls.TextBox)e.Item.Cells[4].Controls[0];
System.Web.UI.WebControls.TextBox st3=new
System.Web.UI.WebControls.TextBox();
st3=(System.Web.UI.WebControls.TextBox)e.Item.Cells[3].Controls[0];
System.Web.UI.WebControls.TextBox st4=new
System.Web.UI.WebControls.TextBox();
st4=(System.Web.UI.WebControls.TextBox)e.Item.Cells[2].Controls[0];
System.Web.UI.WebControls.RadioButtonList st5=new
System.Web.UI.WebControls.RadioButtonList();
st5=(System.Web.UI.WebControls.RadioButtonList)e.Item.Cells[1].FindControl(­"rblmood");
System.Web.UI.WebControls.Image imgDaily = new
System.Web.UI.WebControls.Image();
imgDaily=(System.Web.UI.WebControls.Image)e.Item.Cells[1].FindControl("imgm­");
System.Web.UI.WebControls.TextBox st6=new
System.Web.UI.WebControls.TextBox();
st6=(System.Web.UI.WebControls.TextBox)e.Item.Cells[0].FindControl("txtname­");
SqlCommand myCommand=new SqlCommand();
myCommand.Connection=con;
myCommand.CommandText="insert into DashBoard
(ObjectiveAchieved,Objective,MoodToday,Name) values
(@ObjectiveAchieved, @Objective,@MoodToday,@Name)";
myCommand.Parameters.Add(new
SqlParameter("@ObjectiveAchieved",SqlDbType.Text));
myCommand.Parameters["@ObjectiveAchieved"].Value=st.Text;
myCommand.Parameters.Add(new
SqlParameter("@Objective",SqlDbType.Text));
myCommand.Parameters["@Objective"].Value=st1.Text;
myCommand.Parameters.Add(new SqlParameter("@Workinghrs",SqlDbType.Char,
45));
myCommand.Parameters["@Workinghrs"].Value=st2.Text;
myCommand.Parameters.Add(new SqlParameter("@Loggedout",SqlDbType.Char,
45));
myCommand.Parameters["@Loggedout"].Value=st3.Text;
myCommand.Parameters.Add(new SqlParameter("@Loggedin",SqlDbType.Char,
45));
myCommand.Parameters["@Loggedin"].Value=st4.Text;
myCommand.Parameters.Add(new
SqlParameter("@MoodToday",SqlDbType.Text));
myCommand.Parameters["@MoodToday"].Value=st5.SelectedValue;
myCommand.Parameters.Add(new SqlParameter("@Name",SqlDbType.Text));
myCommand.Parameters["@Name"].Value=st6.Text;
if(e.Item.Cells[1].Equals("Good Mood"))
{
imgDaily.ImageUrl = "IS_dashboard/Moods/laughing.gif";

}


else
{
imgDaily.ImageUrl = "IS_dashboard/Moods/sad.gif";

}


con.Open();
myCommand.ExecuteNonQuery();
con.Close();
dgis.EditItemIndex=-1;
BindDataGrid();
break;
case "Cancel":
break;
case "Edit":
dgis.EditItemIndex = e.Item.ItemIndex;
EditCommandColumn ecc = (EditCommandColumn) dgis.Columns[7];
ecc.UpdateText = "Insert";
break;

}


Fill();
InsertEmpty();
Bind();

}


protected void rblmood_SelectedIndexChanged(object sender,
System.EventArgs e)
{
RadioButtonList rbl = (RadioButtonList)sender;
Control parent = rbl.Parent;
while(!(parent is System.Web.UI.WebControls.DataGridItem))
{
parent = parent.Parent;


}
}


protected int SetState(object st)
{
string state = st.ToString();

if(state.Equals("True"))
{
return 0;


}


else
{
return 1;


}
}


Thanks.




AnswerRe: Images in datagrid! Pin
varshavmane14-Mar-07 3:29
varshavmane14-Mar-07 3:29 
GeneralRe: Images in datagrid! Pin
nclauder14-Mar-07 5:00
nclauder14-Mar-07 5:00 
QuestionLoad Report Failed Error in CrystalReport Pin
siddisagar14-Mar-07 0:00
siddisagar14-Mar-07 0:00 
AnswerRe: Load Report Failed Error in CrystalReport Pin
Sylvester george14-Mar-07 0:19
Sylvester george14-Mar-07 0:19 
Questionlogin form + asp.net 2.0 + c# Pin
ritu432113-Mar-07 23:40
ritu432113-Mar-07 23:40 
AnswerRe: login form + asp.net 2.0 + c# Pin
Sylvester george13-Mar-07 23:53
Sylvester george13-Mar-07 23:53 
GeneralRe: login form + asp.net 2.0 + c# Pin
ritu432114-Mar-07 0:04
ritu432114-Mar-07 0:04 
GeneralRe: login form + asp.net 2.0 + c# Pin
Sylvester george14-Mar-07 0:09
Sylvester george14-Mar-07 0:09 
QuestionPaging Pin
vengaqua13-Mar-07 23:33
vengaqua13-Mar-07 23:33 
AnswerRe: Paging Pin
siddisagar14-Mar-07 0:45
siddisagar14-Mar-07 0:45 
GeneralRe: Paging Pin
vengaqua14-Mar-07 1:09
vengaqua14-Mar-07 1:09 
GeneralRe: Paging Pin
vengaqua14-Mar-07 2:30
vengaqua14-Mar-07 2:30 
GeneralRe: Paging Pin
siddisagar14-Mar-07 21:15
siddisagar14-Mar-07 21:15 
GeneralRe: Paging Pin
siddisagar9-Apr-07 2:34
siddisagar9-Apr-07 2:34 
QuestionCapicom encryption - require clarification Pin
anufabian13-Mar-07 23:13
anufabian13-Mar-07 23:13 
QuestionDate format Pin
vengaqua13-Mar-07 23:12
vengaqua13-Mar-07 23:12 
AnswerRe: Date format Pin
Sun Rays13-Mar-07 23:23
Sun Rays13-Mar-07 23:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.